My Easy Java Solution


  • 0
    C
    public TreeNode invertTree(TreeNode root) {
            if(root == null) return root;
            TreeNode temp =  root.left;
            root.left = root.right;
            root.right = temp;
            invertTree(root.left);
            invertTree(root.right);
            return root;
        }

  • 0
    C

    using temp to invert,then recursive.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.