/**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
int min(int i,int j){
if(i<j) return i;
return j;
}
int minDepth(struct TreeNode* root) {
if(!root) return 0;
if(!root->left&&!root->right) return 1;
int a=9999,b=9999;
if(root->left) a=minDepth(root->left);
if(root->right) b=minDepth(root->right);
return min(a,b)+1;
}
结果:
标签:right,TreeNode,struct,int,最小,111,二叉树,root,left From: https://www.cnblogs.com/llllmz/p/18054368