Priority queue || Very simple and easy to understand solution
\n# Approch\n- insert all items to a min heap priority queue( smallest value at top )\n- Also evaluate the total sum of the array nums\n- Iterate over queries a
\n# Approch\n- insert all items to a min heap priority queue( smallest value at top )\n- Also evaluate the total sum of the array nums\n- Iterate over queries and then keep on setting 0 as per the query\n\n\n# Code\n\n```\nvector<long long> unmarkedSumArray(vector<int>& nums, vector<vector<int>>& queries) {\n    long long sum = 0;\n    vector<long long> ans;\n    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int,int>>> pq;\n    for(auto i = 0; i < nums.size(); ++i){ \n        sum += nums[i]; pq.push({nums[i], i}); \n    }\n\n    for(auto q: queries){\n        sum -= nums[q[0]];\n        nums[q[0]] = 0;\n        while(pq.size() && q[1]){\n            if(nums[pq.top().second]){ \n                sum -= nums[pq.top().second];  \n                nums[pq.top().second] = 0; \n                q[1]--; \n            }\n            pq.pop();\n        }\n        ans.push_back(sum);\n    }\n    return ans;\n}\n\n```\n\n\n---\n\n<b> Here is an article of my last interview experience - A Journey to FAANG Company, I recomand you to go through this to know which all resources I have used & how I cracked interview at Amazon:\nhttps://leetcode.com/discuss/interview-experience/3171859/Journey-to-a-FAANG-Company-Amazon-or-SDE2-(L5)-or-Bangalore-or-Oct-2022-Accepted\n\n---
['C++']