206. Reverse Linked List (LL)

  熟悉了一下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 }

 

posted @ 2018-08-17 23:21  jasoncool1  阅读(119)  评论(0编辑  收藏  举报