剑指offer:镜像二叉树

一、问题描述

 

 将源二叉树转换成镜像二叉树,主要是左右节点互换

二、代码实现:

class Solution:

    def Mirror(self, root):
        # write code here
        if not root:
            return root
        root.left,root.right=root.right,root.left
        self.Mirror(root.left)
        self.Mirror(root.right)
        return root

 

posted @ 2021-02-04 16:58  小千北同学超爱写代码  阅读(25)  评论(0编辑  收藏  举报