Reverse Linked List
Reverse Linked List
问题:
Reverse a singly linked list.
思路:
插入排序的应用
我的代码:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
public class Solution { public ListNode reverseList(ListNode head) { if(head==null || head.next==null) return head; ListNode dummy = new ListNode(-1); dummy.next = head; ListNode cur = head.next; while(cur != null) { ListNode next = cur.next; cur.next = dummy.next; dummy.next = cur; cur = next; } head.next = null; return dummy.next; } }
posted on 2015-05-05 14:44 zhouzhou0615 阅读(107) 评论(0) 编辑 收藏 举报