206. Reverse Linked List

Reverse a singly linked list.

含义:翻转一个单列表

 1     public ListNode reverseList(ListNode head) {
 2         ListNode newHead=null;
 3         while (head != null)
 4         {
 5             ListNode next = head.next;
 6             head.next = newHead;
 7             newHead = head;
 8             head = next;
 9         }
10         return newHead;        
11     }

 

 类似题目:92. Reverse Linked List II

posted @ 2017-10-25 15:01  daniel456  阅读(91)  评论(0编辑  收藏  举报