MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / helper

Method helper

src/com/blankj/easy/_0107/Solution.java:24–32  ·  view source on GitHub ↗
(List<List<Integer>> list, TreeNode root, int level)

Source from the content-addressed store, hash-verified

22 }
23
24 private void helper(List<List<Integer>> list, TreeNode root, int level) {
25 if (root == null) return;
26 if (level >= list.size()) {
27 list.add(0, new LinkedList<>());
28 }
29 helper(list, root.left, level + 1);
30 helper(list, root.right, level + 1);
31 list.get(list.size() - level - 1).add(root.val);
32 }
33
34 public static void main(String[] args) {
35 Solution solution = new Solution();

Callers 1

levelOrderBottomMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected