Article From:https://www.cnblogs.com/goPanama/p/9495876.html

  Familiarity with the construction and processing of LinkedList.

 

 

 

 

 1 class Solution {
 2    public ListNode reverseList(ListNode head) {
 3        if(head == null) return head;
 4        if(head.next == null) return head;
 5        
 6        ListNode a = head;
 7        ListNode b = head.next;
 8        ListNode c = a;
 9        head.next = null;
10        while(b != null) {
11            c = a;
12            a = b;
13            b = b.next;
14            a.next = c;
15             
16        }
17        return a;      
18    }
19 }

 

Similar Posts:

Link of this Article: 206. Reverse Linked List (LL)

Leave a Reply

Your email address will not be published. Required fields are marked *