Count Dropped Requests
Reported by candidates from JP Morgan's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
JP Morgan asked this in January 2026, and it's a simulation problem dressed up as a threading question. You're tracking thread availability over time as requests arrive. The trap is overthinking the concurrency aspect. It's not about locks or race conditions. It's about maintaining a simple state: how many threads are free right now, and what happens when a request lands. StealthCoder can walk you through the state machine if you freeze mid-interview.
The problem
A server maintains a pool of processing threads. The input array describes events in chronological order. Each thread can serve at most one request and is then destroyed. If a request arrives when no threads are available, that request is dropped. Return the number of dropped requests. The first request consumes the only available thread. The second request arrives when the pool is empty, so it is dropped.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The pattern is straightforward simulation with a priority queue or event timeline. Each request either consumes a free thread (and that thread is destroyed after serving, removing it from the pool), or it gets dropped. The key insight is that you need to track when threads become available again. If thread execution takes time (explicit or implicit in the problem), you must process events in order, remove threads from availability as they're assigned, and mark them as free again once their service window closes. Many candidates miss that threads are destroyed after use, not recycled. Others forget to sort or track the timeline correctly. Walk through the example step by step, track state explicitly, and you'll avoid the common drops.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Count Dropped Requests 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 for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.
Get StealthCoderRelated leaked OAs
You've seen the question.
Make sure you actually pass JP Morgan's OA.
JP Morgan reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Count Dropped Requests FAQ
Do I need to track exact timing or just thread count?+
Both. Threads become free at specific times. You need to know which requests arrive while threads are actually available, not just count total threads. Process events chronologically, update thread availability as requests complete, then check if the next request has a free thread waiting.
What's the trick with thread destruction?+
Threads are destroyed after serving one request. Don't recycle them. If the pool starts with N threads, each serves one request and vanishes. Once all N are consumed, every new request is dropped unless a prior thread finishes in time. That's the bottleneck.
How do I handle the timeline if requests and completions overlap?+
Sort all events by timestamp. Process in order: mark threads as busy when assigned, free them when their service window ends. Before dropping a request, check if any thread will be free by that request's arrival time. Early submissions matter.
Is this a hard-to-code problem or a hard-to-understand problem?+
Hard to understand. The code is simple once you know the rule. Spend two minutes on paper modeling the examples. Don't jump to code until you've traced through state changes manually.
Will this still be asked if I interview at JP Morgan again?+
Yes. Thread pool and request drop problems are evergreen at companies handling real-time systems. The specific wording changes, but the simulation pattern is stable. Master it now.