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