Self1 LeetCode 226. Invert Binary Tree - Python LeetCode 226. Invert Binary Tree - Python Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Solution : class Solution(object): def invertTree(self, root): stack = [root] while stack: node = stack.pop() if node: node.left, node.right = node.right, node.left stack += node.left, node.right return root (솔루션 출처) https://gist.github.com/ryuji0123/ 더보기 # .. 2020. 8. 9. 이전 1 다음