You're given an array of n integers, nums, and another array of at most n integers, operations, where each integer represents an operation to be performed on nums.
- If the operation number is
k >= 0, the operation is "delete the number at indexkin the original array if it has not been deleted yet. Otherwise, do nothing." - If the operation number is
-1, the operation is "delete the smallest number innumsthat has not been deleted yet, breaking ties by smaller index."
Return the state of nums after applying all the operations. Every number in operations is guaranteed to be between -1 and n-1, included.
Example:
- Input:
nums = [50, 30, 70, 20, 80], operations = [2, -1, 4, -1] - Output:
[50]
50
0
30
1
70
2
20
3
80
4
deleted=[]
Step 1 / 6
Step 1:
Init heap with (val, idx) and empty deleted set.
Focus: default