首页 > 其他 > 详细

[LeetCode]206. Reverse Linked List

时间:2017-05-06 09:27:46      阅读:246      评论:0      收藏:0      [点我收藏+]

Reverse a singly linked list.

click to show more hints.

 

Subscribe to see which companies asked this question.

 1 public ListNode reverseList(ListNode head) {
 2             if(head==null) return null;
 3             if(head.next==null) return head;
 4             ListNode pre = head;
 5             ListNode cur = head.next;
 6             pre.next = null;
 7             ListNode next;
 8             while(cur != null){
 9                 next = cur.next;
10                 cur.next = pre;
11                 pre = cur;
12                 cur = next;
13             }
14             return pre;
15         }

 

[LeetCode]206. Reverse Linked List

原文:http://www.cnblogs.com/zle1992/p/6815467.html

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