# Definition for a binary tree node.
# class TreeNode(object):
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

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

 

相关文章:

  • 2021-07-25
  • 2021-08-16
  • 2021-06-16
  • 2022-02-14
  • 2021-12-20
  • 2021-08-28
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-24
  • 2022-02-02
  • 2021-07-27
  • 2022-01-27
  • 2021-05-30
  • 2021-07-31
相关资源
相似解决方案