category-wise-problems

contains category wise problems(data structures, competitive) of popular platforms.

View the Project on GitHub mayankdutta/category-wise-problems

328. Odd Even Linked List , Medium

method 1

optimal method

Code ```cpp class Solution { public: ListNode* oddEvenList(ListNode* head) { if (head == nullptr) return head; ListNode *even = head -> next; ListNode *odd = head; ListNode *evenHead = even; while (even != nullptr and even -> next != nullptr) { odd -> next = odd -> next -> next; even -> next = even -> next -> next; odd = odd -> next; even = even -> next; } odd -> next = evenHead; return head; } }; ```