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 76b63ad commit 934a0afCopy full SHA for 934a0af
maximum-depth-of-binary-tree/kimjunyoung90.java
@@ -0,0 +1,25 @@
1
+public class Solution {
2
+ public int maxDepth(TreeNode root) {
3
+ if (root == null) return 0;
4
+ return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
5
+ }
6
+}
7
+
8
+class TreeNode {
9
+ int val;
10
+ TreeNode left;
11
+ TreeNode right;
12
13
+ TreeNode() {
14
15
16
+ TreeNode(int val) {
17
+ this.val = val;
18
19
20
+ TreeNode(int val, TreeNode left, TreeNode right) {
21
22
+ this.left = left;
23
+ this.right = right;
24
25
0 commit comments