public static ListNode reverse(ListNode head) {
ListNode pre = null, next = null;
while (head != null) {
next = head.next;
head.next = pre;
pre = head;
head = next;
}
return pre;
}