AFFILIATE LINKS
Great resource I use to learn algorithms.
40% off Tech Interview Pro: http://techinterviewpro.com/terriblewhiteboard
20% off CoderPro: http://coderpro.com/terriblewhiteboard
/**
* @param {ListNode} head
* @return {ListNode}
*/
var oddEvenList = function(head) {
if (head === null) {
return null;
}
let odd = head;
let even = head.next;
let evenHead = even;
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;
};