Javascript bfs + binary search 5044ms
\n////////////////////////// Template ////////////////////////////////////\nfunction Bisect() {\n    return { insort_right, insort_left, bisect_left, bisect_rig
```\n////////////////////////// Template ////////////////////////////////////\nfunction Bisect() {\n    return { insort_right, insort_left, bisect_left, bisect_right }\n    function insort_right(a, x, lo = 0, hi = null) {\n        lo = bisect_right(a, x, lo, hi);\n        a.splice(lo, 0, x);\n    }\n    function bisect_right(a, x, lo = 0, hi = null) { // > upper_bound\n        if (lo < 0) throw new Error(\'lo must be non-negative\');\n        if (hi == null) hi = a.length;\n        while (lo < hi) {\n            let mid = parseInt((lo + hi) / 2);\n            a[mid] > x ? hi = mid : lo = mid + 1;\n        }\n        return lo;\n    }\n    function insort_left(a, x, lo = 0, hi = null) {\n        lo = bisect_left(a, x, lo, hi);\n        a.splice(lo, 0, x);\n    }\n    function bisect_left(a, x, lo = 0, hi = null) { // >= lower_bound\n        if (lo < 0) throw new Error(\'lo must be non-negative\');\n        if (hi == null) hi = a.length;\n        while (lo < hi) {\n            let mid = parseInt((lo + hi) / 2);\n            a[mid] < x ? lo = mid + 1 : hi = mid;\n        }\n        return lo;\n    }\n}\n///////////////////////////////////////////////////////////////////\n\nconst minReverseOperations = (n, p, banned, k) => {\n    let res = Array(n).fill(-1), evenOdd = [[], []], q = [p], bi = new Bisect();\n    if (k == 1) {\n        res[p] = 0;\n        return res;\n    }\n    banned = new Set(banned);\n    for (let i = 0; i < n; i++) {\n        if (i != p && !banned.has(i)) evenOdd[i % 2].push(i);\n    }\n    res[p] = 0;\n    while (q.length) {\n        let cur = q.shift();\n        let L = Math.max(-(k - 1), k - 1 - cur * 2), R = Math.min(k - 1, -(k - 1) + (n - cur - 1) * 2); // caculate the jump range\n        let x = (cur + k - 1) % 2, idx = bi.bisect_left(evenOdd[x], cur + L);\n        while (1) { // not reached position, can be jump from current position (cur -> next)\n            let next = evenOdd[x][idx];\n            if (next == undefined || next > cur + R) break;\n            res[next] = res[cur] + 1;\n            q.push(next);\n            evenOdd[x].splice(idx, 1);\n        }\n    }\n    return res;\n};\n```
['Binary Search', 'Breadth-First Search', 'JavaScript']