invert1 [LeetCode] Invert Binary Tree 파이썬(recursion) recursively # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def invertTree(self, root: TreeNode) -> TreeNode: def recu(node): if node == None: return recu(node.left) recu(node.right) node.left, node.right = node.right, node.left recu(root) return root iteratively cl.. 2021. 4. 5. 이전 1 다음