首页 > 其他 > 详细

206. Reverse Linked List (LL)

时间:2018-08-18 00:07:27      阅读:147      评论:0      收藏:0      [点我收藏+]

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

 

206. Reverse Linked List (LL)

原文:https://www.cnblogs.com/goPanama/p/9495876.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!