Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

invert linked list js

const reverseList = function(head) {
    let prev = null;
    while (head !== null) {
        let next = head.next;
        head.next = prev;
        prev = head
        head = next;
    }
    return previous;
};
Source by wsvincent.com #
 
PREVIOUS NEXT
Tagged: #invert #linked #list #js
ADD COMMENT
Topic
Name
4+9 =