Simple Iterative Javascript Solution


  • 1
    R
    function revList(head) {
      let prev = null;
      let curr = head;
      while (curr){
        const temp = curr.next;
        curr.next = prev;
        prev = curr;
        curr = temp;
      }
      return prev;
    }
    

Log in to reply
 

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