Maximum Depth of Binary Tree LeetCode solution in Java

1
class Solution {
2
public int maxDepth(TreeNode root) {
3
// Base Condition
4
if (root == null) return 0;
5
// Hypothesis
6
int left = maxDepth(root.left);
7
int right = maxDepth(root.right);
8
// Induction
9
return Math.max(left, right) + 1;
10
}
11
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0