Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 466 Bytes

226._invert_binary_tree.md

File metadata and controls

28 lines (20 loc) · 466 Bytes

226. Invert Binary Tree

题目: https://leetcode.com/problems/invert-binary-tree/

难度:

Easy

典型的递归题

class Solution(object):
    def invertTree(self, root):
        """
        :type root: TreeNode
        :rtype: TreeNode
        """
        if not root:
            return None
        self.invertTree(root.left)
        self.invertTree(root.right)
        root.left, root.right = root.right, root.left
        return root