/* * 328. Odd Even Linked List * 2016-7-9 by Mingyang * 我自己的代码是做的in place并且没有用假头
* 有一个fix节点永远指向第二个节点,也就是偶数位的第一个用来连接rotate回来的奇数末尾节点 */
public ListNode oddEvenList(ListNode head) { if(head==null||head.next==null) return head; ListNode run=head; ListNode fix=head.next; ListNode temp=fix; while(temp!=null&&temp.next!=null){ head.next=temp.next; temp.next=temp.next.next; head.next.next=fix; temp=temp.next; head=head.next; } return run; }