Reported July 2026
Salesforcequeue

ATM Queue Exit Order

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

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

Strip away the ATM story and this Salesforce OA question, reported in July 2026, is a round-robin scheduler. Everyone gets a slice of k units, leftovers go to the back, and you record who finishes. It's a queue problem, and the real question is whether you simulate it or skip the simulation. If you've got the OA in a day or two, this one is very passable. If your brain freezes mid-assessment, StealthCoder runs invisibly as a safety net and hands you the solution on screen.

The problem

There are n people standing in a queue, numbered from 1 to n. Person i wants to withdraw amounts[i] units of money.
The ATM allows at most k units per transaction. If a person still has money left after a transaction, they move to the end of the queue. Otherwise, they leave the queue.
Return the order in which people leave the queue.

Function
atmQueueOrder(amounts: int[], k: int) → int[]

Examples
Example 1
amounts = [2,3,1,4,2]
k = 2
return = [1,3,5,2,4]
People 1, 3, and 5 finish during their first turn. Person 2 finishes before person 4 on their later turns.
The source shared the rule but did not include this exact sample. FastPrep added this small example so the behavior can be checked directly.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The direct approach is a literal queue simulation. Push indices 1..n, pop the front, subtract k from the remaining amount, and either leave (append to the result) or push back. That works but can be slow if one amount is huge and k is tiny. The smarter trick: each person needs ceil(amounts[i]/k) turns. Person i leaves in round ceil(amounts[i]/k). Sort by that round number, and break ties by original index, since within a round the queue order is preserved. That gives O(n log n) with a stable sort. Check it on the example: rounds are 1,2,1,2,1, so the order is 1,3,5,2,4. The common pitfall is breaking ties wrong or using floor division. Also watch for amounts of 0 if they're allowed. StealthCoder is your hedge on the live OA if the tie-break logic slips under pressure.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill ATM Queue Exit Order 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 StealthCoder

Related leaked OAs

⏵ The honest play

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

Salesforce 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.

ATM Queue Exit Order FAQ

How hard is the ATM Queue Exit Order problem really?+

Easy to medium. The brute-force queue simulation is straightforward and passes small inputs. The only real difficulty is spotting that large amounts with a small k can blow up the simulation, which pushes you toward the sorting shortcut.

What's the trick to solving it fast?+

Compute turns needed as ceil(amounts[i]/k) for each person. Whoever needs fewer rounds leaves first. Ties go to the lower original index because the queue order stays stable across rounds. Sort by (rounds, index) and return the indices.

Should I simulate with a queue or use the sorting approach?+

Write the queue simulation first if you want a guaranteed correct baseline. Use the sorting approach if constraints look large. Sorting is O(n log n) and avoids looping through rounds, so it's safer when amounts are big and k is small.

What edge cases break most solutions?+

Wrong tie-breaking, using floor instead of ceiling, and returning 0-based indices when the problem wants 1-based. Also check when k is at least as large as every amount, where the answer is just 1 through n in order.

How do I prepare for this in 48 hours?+

Write the queue simulation from scratch twice, then write the ceil-and-sort version and compare outputs on random small cases. Hand-trace the example [2,3,1,4,2] with k=2 to confirm [1,3,5,2,4]. That covers it.

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

OA at Salesforce?
Invisible during screen share
Get it