Solution using min-heap (priority queue)
Similar to: https://leetcode.com/problems/corporate-flight-bookings/description/\n\n# Complexity\n- Time complexity: O(N*log(N))\n Add your time complexity here
Similar to: https://leetcode.com/problems/corporate-flight-bookings/description/\n\n# Complexity\n- Time complexity: O(N*log(N))\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(N)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    int minMoves(vector<int>& nums, int limit) {\n        int ans = nums.size() / 2;\n        int n = nums.size();\n\n        map<int, int> sums;\n        priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> toPick;\n        priority_queue<int, vector<int>, greater<int>> picked;\n        int nonPick = 0;\n        for (int i = 0; i < nums.size() / 2; i++)\n        {\n            sums[nums[i] + nums[n - 1 - i]]++;\n            toPick.push({min(nums[i], nums[n - 1 - i]) + 1, max(nums[i], nums[n - 1 - i]) + limit});\n        }\n\n        for (const auto &cur: sums)\n        {\n            while (!toPick.empty() && toPick.top()[0] <= cur.first)\n            {\n                picked.push(toPick.top()[1]);\n                toPick.pop();\n            }\n            while (!picked.empty() && picked.top() < cur.first)\n            {\n                nonPick++;\n                picked.pop();\n            }\n\n            ans = min(ans, (int)picked.size() + 2 * ((int)toPick.size() + nonPick) - cur.second);\n        }\n\n        return ans;\n    }\n};\n```
['Heap (Priority Queue)', 'C++']