Skip to content

Commit db57834

Browse files
committed
feat:add Solution.cpp for 0104.Maximum Depth of Binary Tree
1 parent 191aa10 commit db57834

File tree

1 file changed

+9
-0
lines changed
  • solution/0100-0199/0104.Maximum Depth of Binary Tree

1 file changed

+9
-0
lines changed
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) return 0;
5+
int l = maxDepth(root->left);
6+
int r = maxDepth(root->right);
7+
return max(l, r) + 1;
8+
}
9+
};

0 commit comments

Comments
 (0)