Python3 Solution Leveraging Min Heaps, Sets, Enumeration in Linear Time and Linear Space
# Intuition and Approach\nHeaps, Priority Queues, Sorting, Sets, Enumeration\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n$$N$$ := len(nums)\n- Time complexity:\n$$O(N)$$\n\n- Space complexity:\n$$O(N) ( Exp ) O(1) ( Imp )$$\n\n# Code\n```python3 []\n\'\'\'\nURL := https://leetcode.com/problems/mark-elements-on-array-by-performing-queries/description/\n3080. Mark Elements on Array by Performing Queries\n\'\'\'\n# import heapq\nclass Solution:\n    def unmarkedSumArray(self, nums: List[int], queries: List[List[int]]) -> List[int]:\n        m = len(queries)\n        n = len(nums)\n        answer = [-1 for idx in range(m)]\n        minHeap = []\n        unmarkedElSum = sum(nums)\n        visitedIndices = set()\n        for idx, val in enumerate(nums):\n            record = [val,idx]\n            heapq.heappush(minHeap, record)\n        for ansIndex, [index,k] in enumerate(queries):\n            if(index not in visitedIndices):\n                visitedIndices.add(index)\n                unmarkedElSum -= nums[index]\n            while(len(minHeap) > 0 and k > 0):\n                [minEl,minIndex] = heapq.heappop(minHeap)\n                if(minIndex not in visitedIndices):\n                    visitedIndices.add(minIndex)\n                    k -= 1\n                    unmarkedElSum -= minEl\n            answer[ansIndex] = unmarkedElSum\n        return answer\n\n        \n```
['Array', 'Hash Table', 'Sorting', 'Heap (Priority Queue)', 'Simulation', 'Python3']