Skip to content

Commit 53944de

Browse files
authored
104 Maximum Depth of Binary Tree
104 Maximum Depth of Binary Tree
1 parent 8de8606 commit 53944de

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

maxDepth.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
class Solution {
2+
public:
3+
4+
int maxDepth(TreeNode* root) {
5+
if(root == NULL) return 0;
6+
int left = maxDepth(root->left);
7+
int right = maxDepth(root->right);
8+
return 1+max(left, right);
9+
}
10+
};

0 commit comments

Comments
 (0)