//逆置單鏈表,原地操做,只須要遍歷一遍 private ListNode reverse(ListNode head) { ListNode pre = null; ListNode cur = head; while(cur!=null) { ListNode next = cur.next; cur.next = pre; pre = cur; cur = next; } return pre; }