You are given two integer arrays nums and freq of equal length n. Each element nums[i] represents an ID, and the corresponding element freq[i] indicates how many times that ID should be added to or removed from the collection at step i.
Addition of IDs: If freq[i] is positive, it means freq[i] IDs with the value nums[i] are added to the collection at step i.
Removal of IDs: If freq[i] is negative, it means -freq[i] IDs with the value nums[i] are removed from the collection at step i.
Return an array ans of length n, where ans[i] represents the count of the most frequent ID in the collection after the i-th step. If the collection is empty at any step, ans[i] should be 0 for that step.
Input & Output
Constraints
- 1 ≤ nums.length == freq.length ≤ 105
- 1 ≤ nums[i] ≤ 106
- -105 ≤ freq[i] ≤ 105
- freq[i] ≠ 0
- The collection will never have a negative count for any ID