将一个二叉树左右翻转(Java 版)
public class Solution { public TreeNode invertTree(TreeNode root) { if (root == null) { return null; } root.left = invertTree(root.left); root.right = invertTree(root.right); TreeNode tmp = root.left; root.left = root.right; root.right = tmp; return root; } }