Just a runnable solution
Code\n\nimpl Solution {\n    pub fn min_reverse_operations(n: i32, p: i32, banned: Vec<i32>, k: i32) -> Vec<i32> {\n        let mut distances = vec![std::i32::M
# Code\n```\nimpl Solution {\n    pub fn min_reverse_operations(n: i32, p: i32, banned: Vec<i32>, k: i32) -> Vec<i32> {\n        let mut distances = vec![std::i32::MAX; n as usize];\n        for &x in banned.iter() {\n            distances[x as usize] = -1;\n        }\n        let mut nodes = Vec::new();\n        let mut new_nodes = Vec::new();\n        distances[p as usize] = 0;\n        nodes.push(p);\n        while !nodes.is_empty() {\n            let mut i_min = std::i32::MAX;\n            let mut i_max = std::i32::MIN;\n            for &node in nodes.iter() {\n                let base = node - k + 1;\n                let j2i = |j| base + (j - base) * 2;\n                let mut update = |i| {\n                    if distances[i as usize] == std::i32::MAX {\n                        distances[i as usize] = distances[node as usize] + 1;\n                        new_nodes.push(i);\n                    }\n                };\n                let lo = j2i(base.max(0));\n                let hi = j2i((node + k).min(n) - k);\n                for i in (lo..(i_min - 2).min(hi) + 1).step_by(2) {\n                    update(i);\n                }\n                for i in ((i_max + 2).max(lo)..hi + 1).step_by(2) {\n                    update(i);\n                }\n                i_min = i_min.min(lo);\n                i_max = i_max.max(hi);\n            }\n            std::mem::swap(&mut nodes, &mut new_nodes);\n            new_nodes.clear();\n        }\n        for x in distances.iter_mut() {\n            if *x == std::i32::MAX {\n                *x = -1;\n            }\n        }\n        distances\n    }\n}\n```
['Rust']