We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1ef234b commit 028990bCopy full SHA for 028990b
solution/0100-0199/0111.Minimum Depth of Binary Tree/Solution.cpp
@@ -0,0 +1,9 @@
1
+class Solution {
2
+public:
3
+ int minDepth(TreeNode* root) {
4
+ if (!root) return 0;
5
+ if (!root->left) return 1 + minDepth(root->right);
6
+ if (!root->right) return 1 + minDepth(root->left);
7
+ return 1 + min(minDepth(root->left), minDepth(root->right));
8
+ }
9
+};
0 commit comments