Practice Mark Elements on Array by Performing Queries
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Mark Elements on Array by Performing Queries
Problem Statement
Initially every entry of nums is unmarked. Process queries [index, k] in order. First mark nums[index] if it is not already marked. Then mark up to k of the remaining unmarked entries with the smallest values, breaking equal-value ties by smaller index. If fewer than k remain, mark all of them. Return the sum of the still-unmarked values after each query.
Source: Mark Elements on Array by Performing Queries on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums = [1,2,2,1,2,3,1], queries = [[1,2],[3,3],[4,2]]
[8,3,0]
# Example 2
nums = [1,4,2,3], queries = [[0,1]]
[7]
Constraints
Related LeetCode Problems
Practice more problems similar to Mark Elements on Array by Performing Queries.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.