Reported October 2026
IBMsliding window

Query Type Frequency Window

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

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

IBM reported this one in October 2026, and the trap is easy to miss if you rush. It looks like a counting problem, but a plain frequency map over the whole log gives wrong answers because the 600-second window matters. Group timestamps by query type, then slide a window over each group. Your OA is probably tomorrow, so know the pattern cold: hash table plus sliding window. If you blank mid-assessment, StealthCoder runs invisibly on your desktop and can hand you the solution while the proctor sees nothing.

The problem

You are given n query logs, where each log entry includes:
timestamps[i]: the time of the query in seconds (sorted in non-decreasing order)
queryTypes[i]: the query type recorded at that time
A query type should be included in the result if:
There exists at least one 600-second window in which that query type appears at least threshold times.
Return:
All query types that meet this condition, sorted in increasing (lexicographical) order
An empty array if none qualify

Function
findFrequentQueryTypes(timestamps: int[], queryTypes: String[], threshold: int) → String[]

Examples
Example 1
timestamps = [100, 150, 200, 250, 700]
queryTypes = ["Q1", "Q1", "Q1", "Q2", "Q1"]
threshold = 2
return = ["Q1"]
The table below shows the time window during which the query type appeared at least threshold times, along with its corresponding frequency count:
Query Types Frequency Table
Time WindowQuery TypeFrequency Count
[101, 700]Q13
The query type "Q1" occurs 3 times between timestamps 101 and 700, which is within a 600-second window. Since threshold = 2, "Q1" exceeds the required frequency. Hence, the answer is ["Q1"].

Constraints
1 <= n <= 2 * 10^5
1 <= threshold <= 2 * 10^5
1 <= length of queryTypes[i] <= 10

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick: bucket timestamps by query type in a hash map. Since the input is already sorted, each bucket is sorted too. For each bucket, run two pointers. Advance the right pointer, and move the left pointer while timestamps[right] - timestamps[left] exceeds the window. If the window size reaches threshold, add the type to the result and stop scanning that bucket. The edge case that breaks naive solutions is the window boundary. Example 1 shows [101, 700] as a valid window, so a window is 600 seconds wide inclusive of both ends, a span of 600 between the first and last timestamp. Check that off-by-one against the example before you submit. Another pitfall is counting a type's total occurrences, which ignores the window entirely. Sort the result at the end. Total cost is O(n + k log k) for k qualifying types. If the boundary logic slips under pressure, StealthCoder is the safety net during the live OA.

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 Query Type Frequency Window 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

⏵ The honest play

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

IBM 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.

Query Type Frequency Window FAQ

What's the trick in the IBM query type frequency window problem?+

Group timestamps by query type in a hash map, then slide a two-pointer window over each group. Because the input is sorted, each group is already sorted. If any window of 600 seconds holds at least threshold entries, that type qualifies.

How hard is this problem really?+

Medium-easy. The idea is a standard sliding window, but the boundary condition and the sorted output trip people up. With n up to 2 * 10^5, anything quadratic will time out, so you need the linear pass per group.

What's the boundary condition for the 600-second window?+

Use the example. Timestamps 100 and 700 are both counted in one window, so a gap of exactly 600 is allowed. Shrink the left pointer only when the difference is strictly greater than 600. Test this on the sample before anything else.

Do I need to sort the timestamps first?+

No. The timestamps arrive in non-decreasing order, so appending them to per-type lists keeps each list sorted. You only need to sort the final list of qualifying query types in lexicographical order.

How do I prepare for this in 48 hours?+

Write the sliding window on a sorted array until it's automatic, then add the hash map grouping. Practice the off-by-one check on the sample. Also confirm you return an empty array when nothing qualifies and that you sort the output.

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

OA at IBM?
Invisible during screen share
Get it