1、题目
https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/
2、题意
题解1:递归
class Solution {
public:
int minDepth(TreeNode* root) {
if(!root) return 0;
int left = minDepth(root->left);
int right = minDepth(root->right);
if(!left) return right+1;
if(!right) return left+1;
return min(left,right)+1;
}
};