ctci4.1

复制代码
int highAve(struct tree* root){
    if(root == NULL)
        return 0 ;
    int lefthigh = highAve(root->left);
    int righthigh = highAve(root->right);
    if(abs(lefthigh - righthigh) >=2 )
        return -1;
    else
        return max(lefthigh,righthigh);
}

bool isAve(struct tree* root){
    if(highAve(root) == -1)
        return false;
    else
        return true;
}
复制代码
posted @   lycan785  阅读(174)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示