标签:
Invert a binary tree.
4 / 2 7 / \ / 1 3 6 9
to
4 / 7 2 / \ / 9 6 3 1
递归实现
def invert_tree(root) root.right, root.left = invert_tree(root.left), invert_tree(root.right) if root root end
Leetcode 226 Invert Binary Tree
标签:
原文地址:http://www.cnblogs.com/lilixu/p/4571955.html