Stripe·Software Engineer·Technical Phone Screen
- Design an AccountScheduler class that tracks which accounts are locked until a given timestamp. Implement an is_available(account_id, t) method that returns whether the account can be used at time t.
- Extend the class with an acquire(account_id, t, duration) method that locks an account for a duration starting at t, using the formula: locked_until[account_id] = max(locked_until[account_id], t) + duration.
- Further extend the class with an auto_acquire(t, duration) method that automatically picks the least recently used available account, locks it, and returns its ID. Accounts never previously acquired should be treated as oldest.
“Straightforward to start.”