인프런 커뮤니티 질문&답변
GetHeight 부분... 이렇게 작성하면 망한건가요
작성
·
257
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;
}




