The simplest way on javascript


  • 0
    K
    var reverseList = function(head){
      
      var tmp = null;
      var newHead = null;
      while(head !== null){
        tmp = head;
        head = head.next;
        tmp.next = newHead;
        newHead = tmp;
      }
      
      return newHead;
    }

Log in to reply
 

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