Problem · Queue
ATM Queue Exit Order
Learn this problemProblem statement
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 = 2return = [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.
More Salesforce problems
- Minimize Total Input Cost (for LTMS)Seen Jun 2026
- Count Prime StringsONSITE INTERVIEW · Seen Jun 2026
- Final Pod Counts After LogsOA · Seen May 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
- Generate Seen Binary StringsOA · Seen May 2026
- Update Pod Counts From LogsOA · Seen May 2026
- Minimum Removals to Balance ArrayOA · Seen May 2026
- Key Teams in TreeOA · Seen Mar 2026