Tricky at first  but easy once you got the idea
all you need to do is see what you can achieve with 0 move , 1 move and 2 moves.\n\nhere array ans[i] will denote number of moves required to make all nums[j]+n
all you need to do is see what you can achieve with 0 move , 1 move and 2 moves.\n\nhere array ans[i] will denote number of moves required to make all nums[j]+nums[n-1-j] = i .\nfor pair (x,y) x<y :\n0 move: [x+y,x+y]\n1 move : [x+1 , limit+y]\n2 move: [2,x] and [limit+y+1,2* limit]\n\n\n````\nclass Solution {\npublic:\n    int minMoves(vector<int>& nums, int limit) {\n        int ans[2*limit+2];\n        memset(ans,0,sizeof(ans));\n        int n=nums.size();\n        int st=0,en=n-1;\n        while(st<en){\n            int x=min(nums[st],nums[en]);\n            int y=max(nums[st],nums[en]);\n            \n            //using 1 move we can achieve [x+1,y+limit]\n            ans[x+1]++;\n            ans[y+limit+1]--;\n            \n            //we will need 2 moves to achieve less than (x+1) and greater than (y+limit)\n            ans[y+limit+1]+=2;\n            ans[2*limit+1]-=2;\n            \n            ans[0]+=2;\n            ans[x+1]-=2;\n            \n            st++;en--;\n        }\n        for(int i=1;i<=2*limit;i++){\n            ans[i]+=ans[i-1];\n        }\n        st=0;en=n-1;\n        while(st<en){\n          // we will drecrease 1 here cause we don\'t need to change anyone to achieve nums[st]+nums[en]\n            ans[nums[st++]+nums[en--]]--;\n        }\n        int res=ans[0];\n        for(int i=2;i<=2*limit;i++){\n            res=min(ans[i],res);\n        }\n        return res;\n    }\n};\n````
[]