Clean C++
Link to the original for explanation https://leetcode.com/problems/minimum-moves-to-make-array-complementary/discuss/952773/PythonJava-simple-O(max(n-k))-method
Link to the original for explanation https://leetcode.com/problems/minimum-moves-to-make-array-complementary/discuss/952773/PythonJava-simple-O(max(n-k))-method\nThis is just the C++ version of the code that @yanrucheng wrote, hopefully it helps someone\n```\nclass Solution {\npublic:\n    int minMoves(vector<int>& nums, int limit) {\n        int delta[2 * limit + 2];\n        memset(delta, 0, sizeof(delta));\n        int n = nums.size();\n        for (int i = 0; i < n / 2; i++) {\n            int a = nums[i], b = nums[n - 1 - i];\n            delta[2] += 2;\n            delta[min(a, b) + 1]--;\n            delta[a + b]--;\n            delta[a + b + 1]++;\n            delta[max(a, b) + limit + 1]++;\n        }\n        int res = 2 * n, curr = 0;\n        for (int i = 2; i <= 2 * limit; i++) {\n            curr += delta[i];\n            res = min(res, curr);\n        }\n        return res;\n    }\n};\n```
[]