Rust solution with explanations
First idea, all destination indexes are separated by 2, e.g. k=4, p=6, I can send the value 1 to the indexes: 3, 5, 7, 9\nSecond idea, collect in a tree all pos
First idea, all destination indexes are separated by 2, e.g. k=4, p=6, I can send the value 1 to the indexes: 3, 5, 7, 9\nSecond idea, collect in a tree all possible child indexes for each index from 0 to n-1\nThird idea, do not register all the children but only the first and last\nFourth idea, save already visited index ranges to avoid them and separate even and odd ranges\nFifth idea, browse the tree with Breadth-first search\n\n# Code\n```\nuse std::collections::{HashMap, VecDeque};\nimpl Solution {\n  pub fn min_reverse_operations(n: i32, p: i32, banned: Vec<i32>, k: i32) -> Vec<i32> {\n\n    let banned = banned.iter().map(|v| (v,true)).collect::<HashMap<_, _>>();\n    let mut res: Vec<i32> = vec![-1; n as usize];\n    res[p as usize] = 0;\n\n    if k==1 {\n      return res;\n    }\n\n    let mut tree:Vec<(i32, i32)>  = vec![(0,0);n as usize];\n\n    for i in 0..n {     \n      tree[i as usize] = (\n        std::cmp::max(i - k + 1, k - 1 - i),\n        std::cmp::min(i + k - 1, 2*n - 1 - k - i)\n      );\n    }\n\n    let mut idx = p as usize;\n    let mut ops = 1;\n    let mut queue:VecDeque<(usize, i32)> = VecDeque::new();\n    let mut visited:Vec<(i32,i32)> = Vec::new();\n\n    loop {\n      \n      let (min, max) = tree[idx];\n\n      let mut i = min;\n      \'child_loop: while i <= max {\n\n        for (vmin, vmax) in visited.iter() {\n          if i >= *vmin && i <= *vmax && i&1 == vmin&1 {\n            i = vmax + 2;\n            continue \'child_loop;\n          }\n        }\n\n        if res[i as usize] != -1 || banned.contains_key(&i) {\n          i += 2;\n          continue \'child_loop;\n        }\n\n        res[i as usize] = ops;\n        queue.push_back((i as usize, ops + 1));\n\n        i += 2;\n      }\n\n      let mut update_visited = false;\n      \n      for (vmin, vmax) in visited.iter_mut() {\n        if min&1 != *vmin&1 {\n          continue;\n        }\n        if min >= *vmin && max <= *vmax {\n          update_visited = true;\n          break;\n        }\n        if min <= *vmin && max >= *vmax {\n          *vmin = min;\n          *vmax = max;\n          update_visited = true;\n          break;\n        }\n        if max >= *vmax && min <= *vmax {\n          *vmax = max;\n          update_visited = true;\n          break;\n        }\n        if min <= *vmin && max >= *vmin {\n          *vmin = min;\n          update_visited = true;\n          break;\n        }\n      }\n\n      if !update_visited {\n        visited.push((min, max));\n      }\n\n      (idx, ops) = match queue.pop_front() {\n        Some(q) => q,\n        None => break,\n      };\n    }\n\n    res\n  }\n}\n```
['Rust']