Design a data structure that keeps track of the values in it and answers some queries regarding their frequencies.
Implement the
FrequencyTracker
class.
FrequencyTracker()
: Initializes theFrequencyTracker
object with an empty array initially.void add(int number)
: Addsnumber
to the data structure.void deleteOne(int number)
: Deletes one occurence ofnumber
from the data structure. The data structure may not containnumber
, and in this case nothing is deleted.bool hasFrequency(int frequency)
: Returnstrue
if there is a number in the data structure that occursfrequency
number of times, otherwise, it returnsfalse
.
1 |
|