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 }
类似题目: