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.
1 parent 3a0c211 commit 481c5d2Copy full SHA for 481c5d2
Lintcode/src/chapter3_binary_tree_and_divide_and_conquer/MaximumDepthofBinaryTree.java
@@ -0,0 +1,21 @@
1
+package chapter3_binary_tree_and_divide_and_conquer;
2
+
3
+import classes.TreeNode;
4
5
+public class MaximumDepthofBinaryTree {
6
7
+ /**
8
+ * @param root: The root of binary tree.
9
+ * @return: An integer.
10
+ */
11
12
+ //1 min easy AC! Cheers!
13
+ public int maxDepth(TreeNode root) {
14
+ // write your code here
15
+ if(root == null) return 0;
16
+ int left = maxDepth(root.left);
17
+ int right = maxDepth(root.right);
18
+ return Math.max(left, right)+1;
19
+ }
20
21
+}
0 commit comments