Reported October 2026
Googlequeue

Five-Minute Hit Counter

Reported by candidates from Google's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Google OA. Under 2s to a working solution.
Founder's read

Scanning every past hit on every query is the move that sinks you on this Google OA, reported in October 2026. If the operation list is long, a rescan per query turns into a quadratic mess and the big tests time out. The problem is a hit counter with a 300-second trailing window, and the timestamps arrive in order. That ordering is the whole gift. You're taking this in a day or two, so lock in the queue idea now. StealthCoder sits invisibly on your screen as a safety net if your mind goes blank mid-assessment.

The problem

Simulate a hit counter over a chronological operation sequence. Each operation has an integer type and timestamp:
Type 0 records one hit at that timestamp.
Type 1 queries how many recorded hits occurred during the trailing 300 seconds.
For a query at timestamp t, count hits whose timestamps lie in the half-open interval (t - 300, t]. Multiple hits at the same timestamp count separately. Return the query results in encounter order.

Examples
Example 1
operationTypes = [0,0,0,1,1]
timestamps = [1,2,3,4,300]
return = [3,3]
At timestamp 4, all three hits are recent. At timestamp 300, the hit at timestamp 1 is still inside (0, 300], so the count remains 3.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Timestamps are chronological, so old hits only ever expire, never come back. Keep a queue (or a deque, or a plain array with a head pointer) of hit timestamps. On a hit, push the timestamp. On a query at t, pop from the front while the front is less than or equal to t - 300, then return the queue size. Each hit enters once and leaves once, so the total work is linear. The pitfall is the boundary. The interval is (t - 300, t], so a hit at t - 300 is out, and a hit at 1 is still in for a query at 300. Duplicate timestamps count separately, so don't dedupe into a set. Don't write results for type 0 operations. If you freeze on the pointer logic during the live OA, StealthCoder is the hedge that gets you the clean version.

If you see this problem in your OA tomorrow, the play is to recognize the pattern in 30 seconds. StealthCoder buys you that recognition.

If this hits your live OA

You can drill Five-Minute Hit Counter cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as design hit counter. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Google's OA.

Google reuses patterns across OAs. Built by an Amazon engineer who passed his OA cold and still thinks the filter is broken. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Five-Minute Hit Counter FAQ

What's the trick to the Five-Minute Hit Counter?+

Timestamps are sorted, so use a queue. Push on each hit, and on each query drop everything at or before t - 300 from the front. The remaining queue length is your answer. Every hit is added and removed at most once, so it runs in linear time.

How do I get the window boundary right?+

The interval is half-open: (t - 300, t]. Evict while front <= t - 300. Check it against the example. At t = 300, the hit at 1 stays because 1 > 0. A query at 301 would evict it. Off-by-one here is the most common failed test.

Do I need a hash map to count hits at the same timestamp?+

No. Duplicates count separately, so pushing one entry per hit works fine. A map from timestamp to count also works, but then you must track a running total as you evict. The plain queue is simpler and harder to get wrong.

How hard is this problem really?+

Easy to medium. The logic is short once you see the queue. The difficulty is noticing that brute force rescanning is too slow and getting the boundary exactly right. Most people who miss it fail on the off-by-one, not the algorithm.

How do I prepare for this in 48 hours?+

Write the queue solution from scratch twice, then test the edge cases: query at exactly 300, several hits on one timestamp, a query before any hit, and a query after a long gap. Also practice other sliding-window-over-time problems, since the eviction pattern repeats.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Google.

OA at Google?
Invisible during screen share
Get it