using System;
using System.Collections.Generic;
/*
public class ListNode
{
public int val;
public ListNode next;
public ListNode (int x)
{
val = x;
}
}
*/
class Solution {
/**
* 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
*
*
* @param head ListNode类
* @return ListNode类
*/
public ListNode oddEvenList (ListNode head) {
if(head == null) return null;
ListNode odd = head;
ListNode even = head.next;
ListNode cur = odd;
ListNode nex;
bool isOdd = true;
while(cur != null && cur.next != null){
nex = cur.next;
cur.next= nex.next;
cur = nex;
isOdd = !isOdd;
if(isOdd) odd = cur;
}
odd.next = even;
return head;
}
}