We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a5156f4 commit fd1b535Copy full SHA for fd1b535
104. Maximum Depth of Binary Tree
@@ -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