拼多多笔试编程
private static void print(Node root, String string) { if(orignalRoot==root){ System.out.println(string+root.name); }else { System.out.println(string+"-- "+root.name); } string=string.replace('`', ' '); PriorityQueue<Node> children=root.children; while (!children.isEmpty()) { Node child=children.poll(); String string2; if(children.isEmpty()){//可以不加上| string2=root==orignalRoot?string+"`":string+" `"; print(child, string2); }else { string2=root==orignalRoot?string+"|":string+" |"; print(child, string2); } } }
花了很长时间,终于AC了,也是试了很久,因为不能复制,导致有的空格人眼没看出来。
另外,求问有AC第二题“样本挖掘”的吗?(30%,第一次碰到内存超出了的。。。)