1
2
3
4
5
6
7
8
9
10
11
12
|
Input: nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]
Output:[8,3,0]
Explanation:
We do the following queries on the array:
* Mark the element at index `1`, and `2` of the smallest unmarked elements with the smallest indices if they exist, the marked elements now are `nums = [**_1_** ,_**2**_ ,2,_**1**_ ,2,3,1]`. The sum of unmarked elements is `2 + 2 + 3 + 1 = 8`.
* Mark the element at index `3`, since it is already marked we skip it. Then we mark `3` of the smallest unmarked elements with the smallest indices, the marked elements now are `nums = [**_1_** ,_**2**_ ,_**2**_ ,_**1**_ ,_**2**_ ,3,**_1_**]`. The sum of unmarked elements is `3`.
* Mark the element at index `4`, since it is already marked we skip it. Then we mark `2` of the smallest unmarked elements with the smallest indices if they exist, the marked elements now are `nums = [**_1_** ,_**2**_ ,_**2**_ ,_**1**_ ,_**2**_ ,**_3_** ,_**1**_]`. The sum of unmarked elements is `0`.
|