Skip to content

226 invert binary tree

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

我们一直在努力

apachecn/AiLearning

【布客】中文翻译组