Find Maximum Number Live Threads
Reported by candidates from Snowflake's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
Snowflake asked this in February 2024, and it's a threading/concurrency puzzle that sounds harder than it is. You're given some constraint on thread lifecycle or resource allocation, and you need to find the peak concurrent threads at any point in time. Candidates often overthink the state machine part or miss that you're really tracking intervals. If you blank on the threading semantics during the OA, StealthCoder can read the exact problem and surface the interval-tracking pattern in seconds.
Pattern and pitfall
This is an interval overlap problem disguised as a threading question. Threads have start and end times (or creation/termination events). The trick is sorting events by timestamp, then sweeping left-to-right while maintaining a running count of active threads. Common mistake: not handling the boundary correctly when a thread ends exactly when another starts. Sorting by time, breaking ties by event type (starts before ends on the same tick), then counting active windows will get you there. The pattern is essentially the same as 'merge intervals' or 'meeting rooms.' StealthCoder acts as your safety net if you freeze on the event-ordering logic during the live OA.
Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.
You can drill Find Maximum Number Live Threads 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.
Get StealthCoderRelated leaked OAs
This OA pattern shows up on LeetCode as meeting rooms ii. If you have time before the OA, drill that.
You've seen the question.
Make sure you actually pass Snowflake's OA.
Snowflake reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Find Maximum Number Live Threads FAQ
Is this just counting overlapping intervals?+
Yes. Sort thread start/end times, sweep through, count how many are active at each point. Return the max. The threading language is window dressing. If you can solve 'merge intervals' or 'meeting rooms 2,' you can solve this.
What's the gotcha with thread lifecycle events?+
Threads may start and end on the same timestamp. Decide: does a thread that ends at time T count as active at T? Read the problem carefully. Usually starts take precedence, so sort starts before ends at ties.
Can I use a heap or priority queue?+
You can, but it's overkill. A simple event-based sweep (sort, then iterate with a counter) is O(n log n) and cleaner. Only reach for a heap if the problem has a twist you spot early.
How do I know if the input is thread creation/termination logs?+
The problem will give you events with timestamps and a type (start/create, end/terminate). Each event marks when a thread becomes active or inactive. Parse it into a list of (timestamp, event_type) pairs, then sort and sweep.
Is this pattern still asked at Snowflake?+
Threading and concurrency are core to distributed systems. Snowflake uses this to test interval reasoning and event processing. Yes, variations of this stay on the table. The pattern is classic.