diff --git a/Maximum Depth of Binary Tree b/Maximum Depth of Binary Tree new file mode 100644 index 0000000..d806bb0 --- /dev/null +++ b/Maximum Depth of Binary Tree @@ -0,0 +1,9 @@ +class Solution { +public: + int maxDepth(TreeNode* root) { + if(!root) return 0; + int maxLeft = maxDepth(root->left); + int maxRight = maxDepth(root->right); + return max(maxLeft, maxRight)+1; + } +};