Any other effective methods?


  • 0
    J

    My Java code to solve the problem, but not effective method to solve this problem.

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

Log in to reply
 

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