[codility]tree_height

http://codility.com/demo/take-sample-test/treeheight

非常非常简单的求树的深度。不忍直视。

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

  

上一篇:python学习打卡 day07 set集合,深浅拷贝以及部分知识点补充


下一篇:fbx 模型转换 export