class Solution {
public:
int run(TreeNode *root) {
if (root==NULL){
return 0;
}
int l = run(root->left);
int r = run(root->right);
if (l==0||r==0){
return 1+l+r; //当前节点要么有一个分支,要么是根节点
}
return 1 + min(l,r);
}
};
public:
int run(TreeNode *root) {
if (root==NULL){
return 0;
}
int l = run(root->left);
int r = run(root->right);
if (l==0||r==0){
return 1+l+r; //当前节点要么有一个分支,要么是根节点
}
return 1 + min(l,r);
}
};