Skip to content

Commit fd1b535

Browse files
authored
104. Maximum Depth of Binary Tree
1 parent a5156f4 commit fd1b535

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

104. Maximum Depth of Binary Tree

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// T.C - 0 ms
2+
int maxDepth(TreeNode* root) {
3+
if(!root)return 0;
4+
int leftHeight = maxDepth(root->left);
5+
int rightHeight = maxDepth(root->right);
6+
int ans = max(leftHeight,rightHeight) +1;
7+
return ans;
8+
}

0 commit comments

Comments
 (0)