码迷,mamicode.com
首页 > 其他好文 > 详细

Reverse Linked List

时间:2015-08-01 11:18:23      阅读:96      评论:0      收藏:0      [点我收藏+]

标签:

The material from Youtube: https://www.youtube.com/watch?v=PJzgqT2Ujek

 1 public static ListNode reverse(ListNode head) {
 2         if (head == null || head.next == null) return head;
 3         
 4         ListNode prev = null;
 5         ListNode curr = head;
 6         ListNode next;
 7         
 8         while (curr != null) {
 9             next = curr.next;
10             curr.next = prev;
11             prev = curr;
12             curr = next;
13         }
14         head = prev;
15         return head;
16     }

 

Reverse Linked List

标签:

原文地址:http://www.cnblogs.com/chengeblair/p/4693698.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!