/**
* so easy
* @param head
* @return
*/
public static ListNode oddEvenList(ListNode head) {
// write code here
if (head == null) {
return null;
}
ListNode t1 = head;
ListNode t2 = head.next;
ListNode tail = t1;
ListNode cur = head;
ListNode old = head.next;
while (old != null) {
ListNode node = old.next;
if (node == null) {
break;
}
ListNode node1 = node.next;
cur.next = node;
cur = node;
old.next = node1;
old = node1;
tail = node;
}
tail.next = t2;
return t1;
} 
京公网安备 11010502036488号