C++ || Priority Queue ✔✔
Complexity\n- Time complexity: O(nlogn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(k)\n Add your space complexity here, e.g. O(n) \n\n
## Complexity\n- Time complexity: $$O(nlogn)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(k)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n## Code\n```\nclass Solution {\npublic:\n    int miceAndCheese(vector<int>& reward1, vector<int>& reward2, int k) {\n        vector<int> diff;\n        int n= reward1.size();\n        priority_queue<int,vector<int>,greater<int>> pq;\n        int ans=0;\n        for (int i=0; i<n; i++){\n            int val= (reward1[i]-reward2[i]);\n            ans+= reward2[i];\n            if (k==0)continue;\n            if (pq.size()<k)pq.push(val);\n            else{\n                if (pq.top()<val){\n                    pq.pop();\n                    pq.push(val);\n                }\n            }\n        }\n        while (!pq.empty()){\n            ans+= pq.top();\n            pq.pop();\n        }\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'Greedy', 'Heap (Priority Queue)', 'C++']