-
[알고리즘] #Invert Binary Tree■ Algorithm 2019. 7. 7. 14:08
출처 : https://leetcode.com/problems/invert-binary-tree/
Invert Binary Tree - LeetCode
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
문제
풀이
이 문제도 재귀함수를 이용해서 풀어주면 된다.
먼저 가장 최하단에 있는 왼쪽 자식과 오른쪽 자식의 값까지 내려간 뒤, 두 값을 바꿔준다.
'■ Algorithm' 카테고리의 다른 글
[알고리즘] #Move Zeroes (0) 2019.07.08 [알고리즘] #Reverse Linked List (0) 2019.07.07 [알고리즘] #Single Number (0) 2019.07.06 [알고리즘] #Merge Two Binary Trees (0) 2019.07.06 [알고리즘] #최고의 집합 (0) 2019.06.26