Process Refunds with Bounded Retries
Reported by candidates from Mercor's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.
The Mercor OA reported in September 2026 gives you a refund batch where each request gets at most three payment attempts, and the output strings look like DONE:3 or PENDING:3. It's a simulation problem wearing a fintech costume. Nothing fancy, but the edge cases will bite if you rush. Already-done requests make zero attempts. Empty patterns exist. Patterns longer than three characters get cut off. If you freeze on any of that, StealthCoder is the invisible safety net that reads the problem on screen and hands you a working solution during the live OA.
The problem
Process independent refund requests. alreadyDone[i] tells whether request i was completed before this batch. attemptPatterns[i] lists the outcomes returned by successive payment attempts: S is success and F is failure. If a request is already done, make zero attempts and return DONE:0. Otherwise make at most three attempts and stop on the first success. Return DONE:k after a success on attempt k. If every available attempt among the first three fails, return PENDING:k, where k is the number attempted. Function processRefundRetries(alreadyDone: boolean[], attemptPatterns: String[]) → String[] Examples Example 1 alreadyDone = [false,false,true] attemptPatterns = ["FFS","FFFF","S"] return = ["DONE:3","PENDING:3","DONE:0"] A refund becomes done only after success, and an existing completion performs no attempt. Example 2 alreadyDone = [false,false] attemptPatterns = ["S","FS"] return = ["DONE:1","DONE:2"] The first success stops retries. Example 3 alreadyDone = [] attemptPatterns = [] return = [] An empty batch has no results. Constraints 0 <= alreadyDone.length == attemptPatterns.length <= 100000. Every pattern has length from 0 through 100 and contains only S and F. Requests are independent.
Reported by candidates. Source: FastPrep
Pattern and pitfall
The trick is that there isn't one. Loop over each index, check alreadyDone first, and return DONE:0 immediately if true. Otherwise walk the pattern up to min(3, length) characters. On the first S at position j, return DONE:(j+1). If you finish the walk with no success, return PENDING:k where k is the number of characters you actually tried. That's where people slip. An empty pattern gives PENDING:0, and a pattern like FF gives PENDING:2, not PENDING:3. Also don't read past index 2 even when the pattern has 100 characters. Complexity is O(n) with a tiny constant, so 100000 requests is no problem. Build results in a list and join nothing, just return the array. If you blank on the cap or the empty case during the live OA, StealthCoder is the hedge that catches it.
The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.
You can drill Process Refunds with Bounded Retries 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 Mercor's OA.
Mercor 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.
Process Refunds with Bounded Retries FAQ
How hard is the Mercor refund retries problem really?+
Easy. It's pure simulation with no data structure tricks. The difficulty is reading the rules carefully: done requests skip attempts, three attempt cap, stop on first success. If you code the rules in order, you pass. Most failures come from edge cases, not algorithms.
What's the trick to PENDING:k?+
k is the number of attempts actually made, not always three. Take min(3, pattern length). A pattern of FF returns PENDING:2 and an empty pattern returns PENDING:0. Only a pattern with three or more failures in the first three slots gives PENDING:3.
Do I need to worry about performance with 100000 requests?+
No. Each request does at most three character checks, so total work is about 300000 steps. A single pass with a result array is fine. Don't build strings with repeated concatenation in a nested way, just format each result once.
What edge cases should I test before submitting?+
Test an empty batch, an already-done request with a pattern that would succeed, an empty pattern string, a pattern with success on the fourth character (should be PENDING:3), and success on the first character. Those five cover nearly every bug.
How do I prepare for this in 48 hours?+
Practice a few string-simulation problems where you follow rules in strict order. Write the loop with early returns, then trace the three given examples by hand. Spend the rest of your time on edge cases like zero-length inputs and caps, since that's where this style of question trips people.