LeetCode 328. Odd Even Linked List — JavaScript
Aug 13, 2022
var oddEvenList = function(head) {
if (head === null || head.next === null) return head;
let odd = head;
let even = head.next;
let evenhead = even;
while (odd.next !== null && even.next !== null) {
odd.next = even.next
odd = odd.next
even.next = odd.next
even = even.next
}odd.next = evenhead;
return head
};
用兩條 link list 串接奇數跟偶數,最後合併