1 2 3 4 5 6 7 8 9 10 11 12 13
| public ListNode reverseNode(ListNode l) { if (l == null || l.next == null) return l; ListNode p = l, pre = null, next = null; while (p.next != null) { next = p.next; p.next = pre; pre = p; p = next; } p.next = pre; return p; }
|