diff --git a/solution/0100-0199/0111.Minimum Depth of Binary Tree/Solution.cpp b/solution/0100-0199/0111.Minimum Depth of Binary Tree/Solution.cpp new file mode 100644 index 0000000000000..6dbe2254ca619 --- /dev/null +++ b/solution/0100-0199/0111.Minimum Depth of Binary Tree/Solution.cpp @@ -0,0 +1,9 @@ +class Solution { +public: + int minDepth(TreeNode* root) { + if (!root) return 0; + if (!root->left) return 1 + minDepth(root->right); + if (!root->right) return 1 + minDepth(root->left); + return 1 + min(minDepth(root->left), minDepth(root->right)); + } +}; \ No newline at end of file