c++() simple, easy, small (explained)
\n\n\nRuntime: 228 ms, faster than 49.63% of C++ online submissions for Minimum Moves to Make Array Complementary.\nMemory Usage: 88.8 MB, less than 91.85% of C
![image](https://assets.leetcode.com/users/images/1dbfbe7b-86a8-4628-9095-72e99cc8f4ea_1645009404.1767688.png)\n\n\nRuntime: 228 ms, faster than 49.63% of C++ online submissions for Minimum Moves to Make Array Complementary.\nMemory Usage: 88.8 MB, less than 91.85% of C++ online submissions for Minimum Moves to Make Array Complementary.\n```\nclass Solution {\npublic:\n  int minMoves(vector<int>& nums, int limit) {\n    vector<int>table(limit + limit + 2, 0);\n      \n    for(int i = 0, j = nums.size()-1; i < j; i++, j--){\n      if(nums[i] > nums[j]) swap(nums[i], nums[j]);\n      table[nums[i]+1]--, table[nums[j]+1+limit]++;\n    }\n    \n    int sum = nums.size();\n    for(int i = 0; i != table.size(); i++)\n      table[i] = sum += table[i];\n \n    for(int i = 0, j = nums.size()-1; i < j; i++, j--)\n      table[nums[i] + nums[j]]--;\n    \n    return *min_element(table.begin(), table.end());\n  }\n};\n```
['C', 'C++']