#-*- coding: UTF-8 -*-
# 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):
if root==None:return None
tempRoot=root.left
root.left=root.right
root.right=tempRoot
self.invertTree(root.right)
self.invertTree(root.left)
return root
相关文章
- 01-03[LeetCode145]Binary Tree Postorder Traversal
- 01-03Leetcode_114_Flatten Binary Tree to Linked List
- 01-03[LeetCode] 105. Construct Binary Tree from Preorder and Inorder Traversal_Medium tag: Tree Traversal
- 01-0319.3.5 [LeetCode 104] Maximum Depth of Binary Tree
- 01-03【LeetCode】704. Binary Search 解题报告(Python)
- 01-03[LeetCode&Python] Problem 704. Binary Search
- 01-03[LeetCode] Maximum Depth of Binary Tree 二叉树的最大深度
- 01-03Leetcode 104. Maximum Depth of Binary Tree(二叉树的最大深度)
- 01-03LeetCode Binary Tree Preorder Traversal 先根遍历
- 01-03【LeetCode】297. Serialize and Deserialize Binary Tree 解题报告(Python)