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 5b11a4c commit ca5a8d9Copy full SHA for ca5a8d9
maximum-depth-of-binary-tree/sm9171.java
@@ -0,0 +1,10 @@
1
+class Solution {
2
+ public int maxDepth(TreeNode root) {
3
+ if (root == null) {
4
+ return 0;
5
+ }
6
+ int leftDepth = maxDepth(root.left);
7
+ int rightDepth = maxDepth(root.right);
8
+ return Math.max(leftDepth, rightDepth) + 1;
9
10
+}
0 commit comments