File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ Leetcode刷题记录
23
23
+ No.95 [ cpp] ( cpp/95.cpp )
24
24
+ No.77 [ python] ( python/77.py )
25
25
+ No.97 [ python] ( python/97.py )
26
+ + No.111 [ cpp] ( cpp/111.cpp ) easy
26
27
+ No.529 [ cpp] ( cpp/529.cpp )
27
28
+ No.733 [ cpp] ( cpp/733.cpp )
28
29
Original file line number Diff line number Diff line change
1
+ /* *
2
+ * Definition for a binary tree node.
3
+ * struct TreeNode {
4
+ * int val;
5
+ * TreeNode *left;
6
+ * TreeNode *right;
7
+ * TreeNode(int x) : val(x), left(NULL), right(NULL) {}
8
+ * };
9
+ */
10
+ class Solution {
11
+ public:
12
+ int minDepth (TreeNode* root) {
13
+ if (!root) return 0 ;
14
+ if (!(root->left && root->right )) {
15
+ if (root->left ) return minDepth (root->left ) + 1 ;
16
+ if (root->right ) return minDepth (root->right ) + 1 ;
17
+ }
18
+ return min (minDepth (root->left ), minDepth (root->right )) + 1 ;
19
+ }
20
+ };
You can’t perform that action at this time.
0 commit comments