Skip to content

Commit ee7b73f

Browse files
authored
Merge pull request #619 from daredev127/104-Maximum-Depth-of-Binary-Tree
Created 104-Maximum-Depth-of-Binary-Tree.cs
2 parents fc9bf40 + 6b6f1ad commit ee7b73f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* public int val;
5+
* public TreeNode left;
6+
* public TreeNode right;
7+
* public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {
8+
* this.val = val;
9+
* this.left = left;
10+
* this.right = right;
11+
* }
12+
* }
13+
*/
14+
public class Solution
15+
{
16+
public int MaxDepth(TreeNode root)
17+
{
18+
if (root == null) return 0;
19+
20+
return 1 + Math.Max(MaxDepth(root.left), MaxDepth(root.right));
21+
}
22+
}

0 commit comments

Comments
 (0)