Java 5 line recursive solution

  • 3
    public TreeNode invertTree(TreeNode node) {
        if (node == null) return node;
        TreeNode temp = invertTree(node.left);
        node.left = invertTree(node.right);
        node.right = temp;
        return node;

  • 0
    This post is deleted!

Log in to reply

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