Simple Javascript solution- is this problem supposed to be this easy?

  • 0

    Below is my solution. It was accepted, I'm just wondering if this was supposed to be a more difficult problem or if my answer has some other issue that would be solved with a more complex algorithm. Or maybe it's just javascript making things easy for me.

    var invertTree = function(root) {
        if(root == null) return null;
        var temp = root.left;
        root.left = invertTree(root.right);
        root.right = invertTree(temp);
        return root;

  • 0

    Is it the only one solution you come to?

Log in to reply

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