0ms Java Easy-to-Read Solution


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

Log in to reply
 

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