My simple JAVA solution

  • 5
    1. Set the head to a current node

    2. Keep moving the current node while changing the head with every run

      public class Solution {
      public ListNode reverseList(ListNode head) {

           if (head == null)
               return null;
           if( == null)
               return head;
           ListNode current = head;
           while ( != null){
               //get the next node
               ListNode temp =;
               //take the next node out of the chain and set current's next node to its next node
               //now make the node we took out to point to head  
      = head;
               //reassign the head
               head = temp;
           return head;


Log in to reply

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