"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param root: a TreeNode, the root of the binary tree
@return: nothing
"""
def invertBinaryTree(self, root):
# write your code here
if root is None:
return None
temproot = self.invertBinaryTree(root.left)
root.left = self.invertBinaryTree(root.right)
root.right = temproot
return root
Python, LintCode, 175. 翻转二叉树
最新推荐文章于 2023-03-09 21:34:48 发布