原题:#328_奇偶链表聚集
- 分别设奇偶的链表头 ,其中,奇的链表头为原链表头
- 分别设置奇偶指针
public ListNode oddEvenList(ListNode head) {
if (head == null) return null;
ListNode odd = head, even = head.next, evenHead = even;
while (even != null && even.next != null) {
odd.next = even.next;
odd = odd.next;
even.next = odd.next;
even = even.next;
}
odd.next = evenHead;
return head;
}