题目:
题解:
cpp
struct ListNode* oddEvenList(struct ListNode* head) {
if (head == NULL) {
return head;
}
struct ListNode* evenHead = head->next;
struct ListNode* odd = head;
struct ListNode* even = evenHead;
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;
}