#3092
Most Frequent IDs
specialist · 990 · lc medium +32 · 42.5% accepted · 268 likes · top 24%
Description
You manage a collection of IDs that evolves over n steps, driven by arrays nums and freq. At step i, add freq[i] copies of ID nums[i] to the collection (or remove |freq[i]| copies if negative). Return an array ans where ans[i] is the highest frequency of any single ID after step i, or 0 if the collection is empty.
Code
1
2
3