/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution { public TreeNode invertTree(TreeNode root) { if(root==null) return null; TreeNode temp=root; TreeNode t=null; t=temp.left; temp.left=temp.right; temp.right=t; invertTree(temp.left); invertTree(temp.right); return temp; }}