[C++] Easy to understand solution with detailed Explanation | O(n+limit)
\n    Each pair can have a min sum of 2(1+1) and will require max of 2 moves(changing both the no.s in the pair)\n    \n    Each pair can have a max sum of 2*li
\n    Each pair can have a min sum of 2(1+1) and will require max of 2 moves(changing both the no.s in the pair)\n    \n    Each pair can have a max sum of 2*limit and will require max of 2 moves(changing both the no.s in the pair)\n    \n    actual sum of pair= mid requires 0 moves.\n    l and r are min and max sum of a pair by using 1 move.\n    \n    (2<=target<l) requires 2 moves\n    (l<=target<mid) requires 1 move\n    mid requires 0 moves\n    (mid+1<=target<r) requires 1 move\n    (target>=r) requires 2 moves\n    \n    v[i] is the no. of moves to get a pair sum of i for all pairs\n    \n        v[2]+=2;    //2 moves\n        v[l]--;     //1 move\n        v[mid]--;   //0 move\n        v[mid+1]++; //1 move\n        v[r]++;     //2 moves\n        \n    We mark the changes in moves requires of the sweepline vector v \n    and accumulate the changes to get range specific moves.\n    Then we traverse the v vector to find min moves for any pair sum val i.\n    \n\t```\n\t int minMoves(vector<int>& nums, int limit) {\n        int n=nums.size();\n        vector<int> v(2*limit + 2, 0);\n        \n        int ans=INT_MAX;\n        for(int i=0;i<n/2;i++){\n            int l=min(nums[i],nums[n-i-1])+1;\n            int mid=nums[i]+nums[n-i-1];\n            int r=max(nums[i],nums[n-i-1])+limit+1;\n            v[2]+=2;    //2 moves\n            v[l]--;     //1 move\n            v[mid]--;   //0 move\n            v[mid+1]++; //1 move\n            v[r]++;     //2 moves\n        }\n        \n        for(int i=2;i<2*limit+2;i++){\n\t\t\tv[i]+=v[i-1];  //accumulating results\n           \n            ans=min(ans,v[i]);   //find min of all moves\n        }\n        cout<<"\\n";\n        return ans;\n        \n    }\n\t```\n    \n
[]