/**

Definition for singlylinked list.

public class ListNode {

int val;

ListNode next;

ListNode(int x) { val = x; }

}
*/
public class Solution {
public ListNode oddEvenList(ListNode head) {
if (head == null  head.next == null)
return head;
ListNode even_head = head.next;
ListNode odd = head, even = even_head;
while (even != null && even.next != null) {
odd.next = even.next;
even.next = odd.next;
odd = odd.next;
even = even.next;
}
odd.next = even_head;
return head;}
}