Skip to content

Instantly share code, notes, and snippets.

@cjnghn
Created August 4, 2021 22:42
Show Gist options
  • Save cjnghn/4850bcfdd1af9b3a512dd10ce8b99d14 to your computer and use it in GitHub Desktop.
Save cjnghn/4850bcfdd1af9b3a512dd10ce8b99d14 to your computer and use it in GitHub Desktop.
트 리 기 본
// 트리 높이 = 서브트리들 중 가장 큰 높이 + 1 (루트 포함)
int getHeight(int root) {
int res = 1;
for (int child: children[root])
result = max(result, getHeight(child) + 1);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment