[codility]Tree-height

// you can also use includes, for example:
// #include <algorithm>
int getDepth(tree* T)
{
    if(!T) return 0;
    return max(getDepth(T->l), getDepth(T->r))+1;
}
int solution(tree * T) {
    // write your code in C++98
    return getDepth(T)-1;
}

你可能感兴趣的:([codility]Tree-height)