Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java reverse linked list

    public ListNode reverseList(ListNode head) {
    ListNode prev = null;
    ListNode curr = head;

      while(curr != null){
          ListNode next = curr.next;
          curr.next = prev;
          prev = curr;
          curr = next;
      }
    return prev;
    }
 
PREVIOUS NEXT
Tagged: #java #reverse #linked #list
ADD COMMENT
Topic
Name
8+7 =