class Solution { public TreeNode invertTree(TreeNode node) { if(node==null)return node; TreeNode temp = node.left; node.left = node.right; node.right = temp; node.left = invertTree(node.left); node.right = invertTree(node.right); return node; } }
class Solution { public TreeNode invertTree(TreeNode node) { if(node==null)return node; TreeNode temp = node.left; node.left = node.right; node.right = temp; invertTree(node.left); invertTree(node.right); return node; } }