#3080
Mark Elements on Array by Performing Queries
specialist · 900 · lc medium +31 · 49.1% accepted · 130 likes · top 35%
Description
Given a 0-indexed positive-integer array nums and queries queries[i] = [indexi, ki], start with all elements unmarked. For each query: mark the element at indexi if not already marked, then mark the ki smallest unmarked elements (ties broken by smallest index; mark all if fewer than ki remain unmarked). Return an array where entry i is the sum of unmarked elements after the i-th query.
Code
1
2
3