Tweet Counts Per Frequency
specialist · 990 · lc medium +32 · 45.9% accepted · 220 likes · top 30%
Description
A social media platform analyzes tweet activity over time intervals. A time period can be split into equal-length buckets at a specified frequency (minute = 60s, hour = 3600s, day = 86400s). The last bucket may be shorter.
Implement the TweetCounts class:
- TweetCounts() Initializes the object.
- void recordTweet(String tweetName, int time) Records a tweet named tweetName at the given time (in seconds).
- List<Integer> getTweetCountsPerFrequency(String freq, String tweetName, int startTime, int endTime) For the interval [startTime, endTime] divided into buckets of the given freq, returns a list of tweet counts per bucket.
- freq is one of "minute", "hour", or "day".
Example 1:
Example 2:
Example 3:
Code