mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-19 12:24:34 +08:00
Optimize arrToTree function
in java, cpp, py, go, js, ts.
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user