Tweet Counts Per Frequency
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Build TweetCounts, which logs tweets by name and time (in seconds) and reports activity histograms.
- recordTweet(tweetName, time) logs one tweet. The same name may be logged many times, including at the same second.
- getTweetCountsPerFrequency(freq, tweetName, startTime, endTime) splits the inclusive range [startTime, endTime] into consecutive chunks of 60 seconds ("minute"), 3600 seconds ("hour"), or 86400 seconds ("day"), and returns a list with the number of tweetName tweets in each chunk, in time order.
Chunks are [startTime, startTime + size - 1], [startTime + size, startTime + 2*size - 1], and so on; the last chunk is cut off at endTime, so it may be shorter. The list therefore has (endTime - startTime) // size + 1 entries. A name that was never logged yields all zeros.
Examples
Constraints
- 0 <= time, startTime, endTime <= 10^9
- 0 <= endTime - startTime <= 10^4
- `freq` is one of `"minute"`, `"hour"`, `"day"`
- At most 10^4 calls in total
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.