Easy Understanding || C++ || Deque
`\nclass Solution {\npublic:\n    vector<int> minReverseOperations(int n, int p, vector<int>& banned, int k) {\n        set<int> valid_pos[2];\n        for(int 
```\nclass Solution {\npublic:\n    vector<int> minReverseOperations(int n, int p, vector<int>& banned, int k) {\n        set<int> valid_pos[2];\n        for(int i=0;i<n;i++) valid_pos[i&1].insert(i);\n        for(int x : banned) {\n            valid_pos[0].erase(x);\n            valid_pos[1].erase(x);\n        }\n        deque<pair<int,int>> Q;\n        Q.push_back({0,p});\n        vector<int> ans(n, -1);\n        while(!Q.empty()) {\n            pair<int,int> q=Q.front();\n            Q.pop_front();\n            int pos=q.second;\n            int num_moves=q.first;\n            if (ans[pos]!=-1) continue;\n            // left end is L\n            // L >= max(0,pos-k+1)\n            // L <= min(pos,n-k)            \n            // if left end is L -> 2*L+k-1-pos\n            int minL=max(0,pos-k+1);\n            int maxL=min(pos,n-k);\n                        //printf("pos=%d %d to %d\\n",pos,minn,maxx);\n\n            int minn = 2*minL+k-1-pos;\n            int maxx = 2*maxL+k-1-pos;\n            ans[pos]=num_moves;\n            valid_pos[pos&1].erase(pos);\n            // pos-k to pos+k\n            int parity=(minn&1);\n            auto it = valid_pos[parity].lower_bound(minn);\n            vector<int> to_remove;\n            while(it != valid_pos[parity].end() && *it <= maxx) {\n                Q.push_back({num_moves+1,*it});\n                to_remove.push_back(*it);\n                ++it;\n            }\n            for(int x : to_remove) valid_pos[parity].erase(x);\n        }\n        return ans;\n    }\n};\n``
[]