3-step Space-efficient Javascript Solution
Recommended prerequisite: https://leetcode.com/problems/reverse-linked-list/\n\n\n/**\n * @param {ListNode} head\n * @return {void} Do not return anything, modi
Recommended prerequisite: https://leetcode.com/problems/reverse-linked-list/\n\n```\n/**\n * @param {ListNode} head\n * @return {void} Do not return anything, modify head in-place instead.\n */\nvar reorderList = function(head) {\n    // find middle\n\t// by moving "fast" twice, we\'ll have "slow" in the middle\n    let slow = head\n    let fast = head\n    while (fast.next && fast.next.next) {\n        slow = slow.next\n        fast = fast.next.next\n    }\n\n    // reverse second half\n\t// with reverse linked list solution\n    let prev = null\n    let cur = slow.next\n    while (cur) {\n        let temp = cur.next\n        cur.next = prev\n        prev = cur\n        cur = temp\n    }\n\n    slow.next = null\n\n    // combine two halves\n    let h1 = head\n    let h2 = prev\n\n    // if even, second half will be smaller\n\twhile (h2) {\n        let temp = h1.next\n        h1.next = h2\n        h1 = h2\n        h2 = temp\n    }\n};\n```\n\nexample run:\n```\nhead: 1 -> 2 -> 3 -> 4 -> 5\n\nh1: 1 -> 2 -> 3\nh2: 5 -> 4\n\nhead: 1 -> 5 -> 2 -> 4 -> 3\n```
['JavaScript']