Java
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public int[] minReverseOperations(int n, int p, int[] banned, int k) {\n        TreeSet<Integer> even = new TreeSet<>();\n        TreeSet<Integer> odd = new TreeSet<>();\n        \n        TreeSet<Integer> set;\n        \n        boolean [] skip = new boolean [n];\n        \n        for (int num : banned) {\n            skip[num] = true;\n        }\n        \n        int start = p;\n        \n        // Add values to the set that are not banned\n        for (int i = 0; i < n; ++i) {\n            if (skip[i] || i == p)\n                continue;\n            \n            if (i % 2 == 1)\n                odd.add(i);\n            else\n                even.add(i);\n        }\n        \n        int [] result = new int [n];\n        Arrays.fill(result, -1);\n        \n        Queue<Integer> queue = new LinkedList<>();\n        queue.add(p);\n        \n        int size;\n        int current;\n        int moves = 0;\n        \n        int min, max;\n        \n        Integer key;\n        \n        int mCurrent;\n        \n        while (!queue.isEmpty()) {\n            size = queue.size();\n            \n            \n            while (size-- > 0) {\n                current = queue.remove();\n                \n                result[current] = moves;\n                \n                \n                // calculate min index\n                if (current < k - 1) {\n                    min = (k - 1) - current;\n                }else {\n                    min = current - k + 1;\n                }\n                \n                // calculate max index\n                mCurrent = (n - 1) - current;\n                if (mCurrent < k - 1) {\n                    max = (k - 1) - mCurrent;\n                }else {\n                    max = mCurrent - k + 1;\n                }\n                max = (n - 1) - max;\n                \n                \n                // chose the correct parity set\n                set = min % 2 == 0 ? even : odd;\n                \n                key = set.ceiling(min);\n                \n                // add all values in range to the queue and remove from set\n                while (key != null && key <= max) {\n                    queue.add(key);\n                    set.remove(key);\n                    key = set.ceiling(min);\n                }\n            }\n            \n            ++moves;\n        }\n        \n        \n        return result;\n    }\n}\n```
['Java']