Reported June 2026
Notionhash table

Top Error Types in a Time Window

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

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

The detail that trips people on this Notion OA, reported in June 2026, is the half-open interval. Timestamp 115 in the example sits right on the edge and must not count. You get rows of [timestamp, errorType], filter to [startTime, endTime), count per error type, and return the top k as errorType|count strings. It's a hash-table counting problem with a custom sort, nothing exotic. The traps are small and mean: timestamps come as strings up to 10^18, and ties break alphabetically. If you blank mid-assessment, StealthCoder runs invisibly as a safety net and puts the structure on screen.

The problem

Each response row is [timestamp, errorType], where timestamp is a decimal integer string. Count errors in the half-open interval [startTime, endTime).
Return at most k rows formatted as errorType|count. Rank larger counts first and break equal-count ties by lexicographically smaller error type. If fewer than k error types occur in the interval, return all of them.

Function
topErrorTypes(responses: String[][], startTime: long, endTime: long, k: int) → String[]

Examples
Example 1
responses = [["100","timeout"],["105","validation"],["108","timeout"],["110","auth"],["112","validation"],["115","timeout"]]
startTime = 105
endTime = 115
k = 2
return = ["validation|2","auth|1"]
The left boundary is included and the right boundary is excluded. Validation occurs twice; auth and timeout tie once, so auth wins lexicographically.

Constraints
0 <= responses.length <= 200000.
0 <= timestamp, startTime, endTime <= 10^18 and startTime < endTime.
1 <= k <= 100000.
Error types are non-empty printable ASCII strings containing neither | nor a newline.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is simple. Parse each timestamp as a 64-bit long, skip rows outside startTime <= t < endTime, and increment a hash map keyed by error type. Then sort the map entries by count descending and error type ascending, take the first k, and format each as type|count. With up to 200000 rows that's O(n + m log m), where m is the number of distinct types. You could use a heap of size k, but a full sort is fine here. Pitfalls: parsing into a 32-bit int overflows on values near 10^18. Using <= on endTime gives the wrong answer on the example. Comparing counts but forgetting the lexicographic tiebreak fails the auth versus timeout case. If k exceeds the distinct types, return them all. If you freeze on the comparator during the live OA, StealthCoder is the hedge that gets you unstuck.

StealthCoder is the hedge for the one pattern you didn't drill. It runs invisibly during the screen share.

If this hits your live OA

You can drill Top Error Types in a Time 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. If you're reading this with an OA window open, you're who this was built for.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

Notion reuses patterns across OAs. If you're reading this with an OA window open, you're who this was built for. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Top Error Types in a Time Window FAQ

How hard is the Notion Top Error Types problem really?+

Easy to medium. The algorithm is a frequency map plus a sort. The difficulty is in the details: the half-open interval, 64-bit timestamp parsing, and the two-key sort. If you've written a top-k frequent elements solution before, this is the same shape with a tiebreak.

What's the trick to the tiebreak ordering?+

Sort by count descending first, then by error type ascending using plain string comparison. In the example, auth and timeout both have count 1, so auth comes first. Don't sort by insertion order or rely on map iteration order, because that's unstable across languages.

Do I need a heap or is sorting enough?+

Sorting is enough. Distinct error types are at most the number of rows, so 200000 at worst, and a full sort handles that easily. A min-heap of size k is a valid optimization, but it adds comparator bugs for no real gain here.

What edge cases should I test before submitting?+

Test a timestamp exactly equal to startTime, which counts, and one exactly equal to endTime, which doesn't. Test empty responses, k larger than the distinct types, and timestamps near 10^18 to catch overflow. Also test all-tied counts to verify the alphabetical order.

How do I prepare for this in 48 hours?+

Write one solution from scratch: filter, count in a hash map, sort with a two-key comparator, format the output. Then rerun it on the example and your own edge cases. Practice the comparator in your language, since that's where most bugs hide.

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

OA at Notion?
Invisible during screen share
Get it