ATM Queue Exit Order
Updated
Problem 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.
More Salesforce Phone Screen questions
- Detect a Cycle in a Linked ListPHONE SCREEN · Seen Oct 2026
- Find Rows Common to Two TablesPHONE SCREEN · Seen Oct 2026
- Merge Two Sorted Linked ListsPHONE SCREEN · Seen Oct 2026
- Minimum Window of Required WordsPHONE SCREEN · Seen Aug 2026
- Permutations of Unique CharactersPHONE SCREEN · Seen Aug 2026
- Minimum Window SubstringPHONE SCREEN · Seen Aug 2026
- Optimal Account BalancingPHONE SCREEN · Seen Jul 2026
- Longest Increasing SubsequencePHONE SCREEN · Seen Jul 2026
- Maximal SquarePHONE SCREEN · Seen Jul 2026
- Good Ways to Split an ArrayPHONE SCREEN · Seen May 2026
Similar questions at other companies
- Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
- VIP and Regular Service SchedulerIntuit · PHONE SCREENIntuit interview questions
- Callback Signal RegistryCandid Health · PHONE SCREEN
- Implement a FIFO QueueByteDance · PHONE SCREENByteDance interview questions
- Sliding-Window API Rate LimiterPatreon · PHONE SCREEN · ONSITE INTERVIEWPatreon interview questions
- High-Card Pot GameAffirm · PHONE SCREENAffirm interview questions
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
- Batch API Requests with Retry DelaysDecagon · PHONE SCREENDecagon interview questions
- Music Player Operation SequenceAtlassian · PHONE SCREENAtlassian interview questions
- Rate Limiter Sliding Window With Per-Entity LimitsRoblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions