Practice Tweet Counts Per Frequency
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Tweet Counts Per Frequency
Problem Statement
TweetCounts records recordTweet(tweetName,time) events in seconds. getTweetCountsPerFrequency(freq,tweetName,startTime,endTime) counts that name's events in successive buckets anchored at startTime, including both query endpoints. Bucket sizes are 60, 3600, or 86400 seconds for minute, hour, or day. The last bucket may be shorter; empty buckets count as zero. Practice approach: Store sorted times per name. For each bucket, subtract lower-bound positions at its start and just beyond its inclusive end. Preserve duplicate timestamps and do not align buckets to clock boundaries. Out-of-order records require ordered insertion or deferred sorting.
Source: Tweet Counts Per Frequency on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
["TweetCounts","recordTweet","recordTweet","recordTweet","getTweetCountsPerFrequency","getTweetCountsPerFrequency"] [[],["a",10],["a",69],["a",70],["minute","a",10,70],["hour","a",10,70]]
[null,null,null,null,[2,1],[3]]
Minute buckets are [10,69] and [70,70], whereas the hour query has one shortened bucket.
Constraints
Related LeetCode Problems
Practice more problems similar to Tweet Counts Per Frequency.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.