Skip to content

Commit cde768d

Browse files
authored
Create 104. Maximum Depth of Binary Tree 16 feb (#94)
104. Maximum Depth of Binary Tree
2 parents 72f3133 + b1f2860 commit cde768d

File tree

1 file changed

+9
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)