Earliest Second to Mark Indices II
A hard-tier problem at 20% community acceptance, tagged with Array, Binary Search, Greedy. Reported in interviews at MathWorks and 0 others.
Earliest Second to Mark Indices II is a hard problem that appeared in MathWorks interviews. With a 20% acceptance rate, it's the kind of problem that separates candidates who can synthesize multiple strategies from those who panic under time pressure. The trick isn't one algorithm but knowing when to apply Array techniques, Binary Search, Greedy logic, and Heap operations in concert. If you hit this live and the greedy approach stalls, you need a fast way to recover. StealthCoder surfaces a working solution in seconds, invisible to the proctor, so you don't burn 30 minutes chasing a dead end.
Companies that ask "Earliest Second to Mark Indices II"
Earliest Second to Mark Indices II is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop.
Get StealthCoderThis problem requires you to track which indices get marked and in what order, then find the earliest second where all indices are marked. The naive greedy approach often fails because you can't just mark greedily and expect to hit the minimum time. You need to work backwards from your answer candidates (binary search on the answer), then use a Heap or priority queue to simulate which indices you can actually mark within that time window, applying Greedy selection to prioritize unmarked indices. The Array operations structure your tracking, and Binary Search narrows the search space. Most candidates either skip the backwards simulation or miss that Greedy alone isn't enough without the Heap ordering. When you're live and the first approach bottlenecks, StealthCoder delivers the integrated solution so you keep moving.
Pattern tags
You know the problem.
Make sure you actually pass it.
Earliest Second to Mark Indices II recycles across companies for a reason. It's hard-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Built by an Amazon engineer who used it to pass JPMorgan's OA and system design loop. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Earliest Second to Mark Indices II interview FAQ
Is this problem really that much harder than medium-level array problems?+
Yes. The 20% acceptance rate reflects that it combines four distinct algorithmic concepts. You can't just sort and iterate. You need to recognize when Greedy fails, when Binary Search on the answer helps, and where the Heap keeps you efficient. Medium arrays often use one or two patterns. This forces all four.
Do I need to code a perfect solution first, or can I start with greedy and refine?+
Greedy alone will fail some test cases. You need the Binary Search outer loop and Heap simulation from the start. Walking in with the wrong skeleton wastes 20 minutes. Know the shape before coding.
MathWorks is a hardware/simulation company. Why ask a problem like this?+
MathWorks values algorithmic rigor and efficient constraint solving. Earliest Second mirrors real optimization: given limited resources (time), mark objectives (indices) optimally. It's about systems thinking, not just coding speed.
Should I binary search on seconds or on indices?+
Binary search on seconds. You're looking for the minimum time T such that you can mark all indices by second T. Indices are the constraint; seconds is the answer dimension.
If I blank on the Heap part during the OA, what's my fallback?+
Fallback is to simulate naively: sort all possible operations and mark greedily without the priority queue. Slower, but correct on small inputs. StealthCoder gives you the optimized Heap version in real time, invisible to the proctor.
Want the actual problem statement? View "Earliest Second to Mark Indices II" on LeetCode →