4 / \ 2 7 / \ / \ 1 3 6 9
4 / \ 7 2 / \ / \ 9 6 3 1
public class Solution {
public TreeNode invertTree(TreeNode root) {
if(null == root)
return null;
TreeNode left = root.left;
TreeNode right = root.right;
root.left = right;
root.right = left;
if(left != null)
invertTree(left);
if(right != null)
invertTree(right);
return root;
}
}