My C# Solution 7 Lines - 148 ms


  • 0
    J
    public class Solution {
    public TreeNode InvertTree(TreeNode root) {
        if (root == null) return root;
        TreeNode temp = root.left;
        root.left = root.right;
        root.right = temp;
        root.left = InvertTree(root.left);
        root.right = InvertTree(root.right);
        return root;
    }
    

    }


Log in to reply
 

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