class Solution {
public:
ListNode* oddEvenList(ListNode* head) {
if(head==nullptr) return head;
ListNode *first,*second,*temp,*pre;
first=head;
second=head->next;
temp=head->next;
while(first!=nullptr && second!=nullptr){
first->next=first->next->next;
if(second->next==nullptr) break;
second->next=second->next->next;
pre=first;
first=first->next;
second=second->next;
}
first->next=temp;
return head;
}
};