Skip to content

Commit 032602d

Browse files
authored
Merge pull request haoel#122 from FEIGONG/master
modified: algorithms/cpp/maximumDepthOfBinaryTree/maximumDepthOfBi…
2 parents 2f3a77d + 4eb4806 commit 032602d

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎algorithms/cpp/maximumDepthOfBinaryTree/maximumDepthOfBinaryTree.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,11 @@ class Solution {
4040
}
4141

4242
};
43+
44+
class Solution2 {
45+
public:
46+
int maxDepth(TreeNode *root) {
47+
if (root==NULL) return 0;
48+
return max(maxDepth(root->left), maxDepth(root->right)) + 1;
49+
}
50+
};

0 commit comments

Comments
 (0)