[Codility] Tree Height
해결전략
이진트리 Binary Tree
정답코드
| #include <algorithm> |
| |
| int answer; |
| |
| void DFS(tree* node, int currLength) |
| { |
| if(node == nullptr) return; |
| |
| answer = max(answer, currLength); |
| |
| if(node->l != nullptr){ |
| DFS(node->l, currLength + 1); |
| } |
| if(node->r != nullptr){ |
| DFS(node->r, currLength + 1); |
| } |
| } |
| |
| int solution(tree* T) { |
| |
| DFS(T, 0); |
| |
| return answer; |
| } |
유사문제
2024.02.18 - [⭐ 코딩테스트/Codility] - [Codility] Tree Longest Zigzag
댓글을 사용할 수 없습니다.