码迷,mamicode.com
首页 > 其他好文 > 详细

ctci4.1

时间:2014-10-09 19:06:47      阅读:176      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   sp   div   log   ef   bs   as   

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;
}

ctci4.1

标签:style   blog   color   sp   div   log   ef   bs   as   

原文地址:http://www.cnblogs.com/jilichuan/p/4013697.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!