剑指 Offer 27. 二叉树的镜像

solution

rescursive

class Solution:
    def mirrorTree(self, root: TreeNode) -> TreeNode:
        def helper(node):
            if not node:
                return
            left = helper(node.left)
            right = helper(node.right)
            node.left = right
            node.right = left
            return node
        return helper(root)
上一篇:生成二维码


下一篇:git 拉取免输入帐号密码