Tripped out by this!

  • 0

    Hey guys,

    I've been fairly decent at getting through these algorithm problems so far but something has been tripping me up - that's the code below:

    var reverseList = function(head) {
        if (!head || ! {
            return head;
        var newHead = reverseList(;
        = head; = null;
        return newHead;

    How does modifying head with the = head and the = null affect the return value aka newHead? I know it's an essential step but I can't figure out why changing that affects the return value. Thanks in advance!

Log in to reply

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