my BFS based solution with TreeSet  for Odd and even indexes
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    int ans[] = new int[n];\n    Arrays.fill(ans, -1);\n    boolean vis[] = new boolean[n];\n    for(int x : banned)\n    vis[x] = true; \n    for(int i=0; i<n; i++)\n    {\n     if(vis[i] || i==p)\n     continue; \n     if(i%2==0)\n     even.add(i);\n     else\n     odd.add(i);   \n    }\n    Queue<Integer> q = new LinkedList<Integer>();\n    int min = -1; \n    int max = -1; \n    Integer Key = 0; \n    int current = -1; \n    int distBack = -1; \n    q.add(p);\n    ans[p] = 0; \n    while(!q.isEmpty())\n    {\n     current = q.remove();\n     if(current<k-1)\n     {\n       min = k-1-current ;   \n     } \n     else\n     min = current-k+1;\n     distBack = n - current ;\n     if(distBack<k)\n     {\n       max = k - distBack;\n       max = n-max;    \n     }\n     else\n     max = current+k-1; \n     TreeSet<Integer> ts = min%2==0 ? even : odd; \n     Integer key = ts.ceiling(min);\n\n     while(key!=null && key<=max)\n     {\n       ans[key] = ans[current] + 1;\n       q.add(key); \n       ts.remove(key);\n       key = ts.ceiling(min);  \n     } \n    }\n\n   return ans; \n\n    }\n}\n```
['Java']