// 找到中间节点publicListNodegetMid(ListNode head){ListNode slow = head;ListNode fast = head;while(fast.next !=null&& fast.next.next !=null){
slow = slow.next;
fast = fast.next.next;}return slow;}
将链表中点后面的元素反转(LeetCode #206)
// 对中间节点后面的部分进行反转publicListNodereserve(ListNode head){ListNode pre =null;ListNode cur = head;while(cur !=null){ListNode next = cur.next;
cur.next = pre;
pre = cur;
cur = next;}return pre;}