Optimize arrToTree function

in java, cpp, py, go, js, ts.
This commit is contained in:
Yudong Jin
2023-01-08 19:03:22 +08:00
parent c411969bd1
commit dcc3b2e35b
29 changed files with 222 additions and 114 deletions

View File

@ -8,6 +8,7 @@ package include;
import java.util.*;
class Trunk {
Trunk prev;
String str;
@ -103,4 +104,11 @@ public class PrintUtil {
System.out.println(kv.getKey() + " -> " + kv.getValue());
}
}
public static void printHeap(PriorityQueue<Integer> queue) {
Integer[] nums = (Integer[])queue.toArray();
TreeNode root = TreeNode.arrToTree(nums);
printTree(root);
}
}