Written on
·
248
0
int height = 0;
int maxHeight = 0;
int GetHeight(NodeRef root) {
height++;
if (root->children.empty()) {
return height;
}
for (NodeRef child : root->children) {
GetHeight(child);
if (maxHeight <= height) {
maxHeight = height;
}
height--;
}
return maxHeight;
}