We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 52a7307 + ea2a1f3 commit fb2f631Copy full SHA for fb2f631
2018.12.07-leetcode104/Avalon.md
@@ -0,0 +1,32 @@
1
+/**
2
+ * Definition for a binary tree node.
3
+ * public class TreeNode {
4
+ * int val;
5
+ * TreeNode left;
6
+ * TreeNode right;
7
+ * TreeNode(int x) { val = x; }
8
+ * }
9
+ */
10
+class Solution {
11
+ public int maxDepth(TreeNode root) {
12
+ if (root == null) return 0;
13
+ int nodedeep = 0;
14
+ LinkedList<TreeNode> list = new LinkedList<>();
15
+ list.add(root);
16
+ TreeNode current;
17
+ int len;
18
+ List<Integer> intlist = new ArrayList<>();
19
+ while (!list.isEmpty()) {
20
+ len = list.size();
21
+ for (int i = 0; i < len; i++) {
22
+ current = list.poll();
23
+ if (current.left!=null)
24
+ list.add(current.left);
25
+ if (current.right!=null)
26
+ list.add(current.right);
27
+ }
28
+ nodedeep++;
29
30
+ return nodedeep;
31
32
+}
0 commit comments