c++ short and clear | using line sweep | with comments
moves[i] -> number of moves required to make sum of every pair ar[j] and ar[n-1-j] equal to \'i\'\nusing line sweep technique, we construct the moves array.\nAf
moves[i] -> number of moves required to make sum of every pair ```ar[j```] and ```ar[n-1-j]``` equal to \'i\'\nusing line sweep technique, we construct the ```moves``` array.\nAfter doing changes in `moves` array, we take minimum move required to make possible sums.\nSince the possible sum for any pair in ```ar``` lies in the range of ```[2,2*k]```, we take minimum in this range only.\n\n```\nclass Solution {\npublic:\nint minMoves(vector<int> &ar,int k){\n    int n=ar.size(),ans=n;\n    vector<int> moves(2*k+2,0);\n    for(int i=0;i<n/2;i++){\n        int mn=min(ar[i],ar[n-1-i]),mx=max(ar[i],ar[n-1-i]);\n        moves[mn+1]++,moves[mx+k+1]--;                      //  to make the sum of ar[i]+ar[n-1-i] in the range [mn+1,mx+k] we need to do 1 changes\n        moves[mn+mx]--,moves[mn+mx+1]++;                    //  to make the sum of ar[i]+ar[n-1-i] in the range [mn+mx,mn+mx] we need to do 0 changes\n        moves[mx+k+1]+=2,moves[2*k+1]-=2;                   //  to make the sum of ar[i]+ar[n-1-i] in the range [mx+k+1,2*k] we need to do 2 changes\n        moves[2]+=2,moves[mn+1]-=2;                         //  to make the sum of ar[i]+ar[n-1-i] in the range [2,mn] we need to do 2 changes\n    }\n    for(int i=2;i<=2*k;i++) moves[i]+=moves[i-1],ans=min(ans,moves[i]);\n    return ans;\n}\n};\n```
[]