Account Scheduler - Availability and Acquire
Learn this problemProblem statement
You manage a set of accounts that can be locked until a given time. Process a sequence of time-stamped queries and report availability.
Setup: accountIds is an int[] of account ids. lockedUntil is a String[] where each entry is "accountId,timestamp" giving the time each account is initially locked until (an account not listed is unlocked, i.e. locked until 0).
An account is available at time t when its lock time is <= t (i.e. t >= lockedUntil). Queries arrive in order, with no concurrency:
IS_AVAILABLE <accountId> <t>: outputtrueif the account is available at timet, elsefalse.ACQUIRE <accountId> <duration> <t>: lock the account fordurationtime units starting at the query timet, i.e. set its lock time tot + duration. OutputOK.
Return a String[] with one output line per query, in order.
(Follow-up discussed in the source but not part of this contract: an ACQUIRE with no account id that auto-picks the least-recently-used available account; this draft covers the deterministic explicit-id availability and acquire behavior.)
Function
processScheduler(accountIds: int[], lockedUntil: String[], queries: String[]) → String[]Examples
Example 1
accountIds = [1, 2, 3, 4]lockedUntil = ["1,10", "2,5", "3,0", "4,20"]queries = ["IS_AVAILABLE 1 8", "IS_AVAILABLE 2 8", "IS_AVAILABLE 3 1", "IS_AVAILABLE 4 21"]return = ["false", "true", "true", "true"]Example 2
accountIds = [1, 2, 3, 4]lockedUntil = ["1,10", "2,5", "3,0", "4,20"]queries = ["IS_AVAILABLE 3 1", "ACQUIRE 3 5 1", "IS_AVAILABLE 3 4", "IS_AVAILABLE 3 6"]return = ["true", "OK", "false", "true"]Constraints
lockedUntilentries are"accountId,timestamp"; unlisted accounts are locked until 0.- An account is available at
tifft >= lockedUntil. ACQUIRE accountId duration tsets the lock time tot + durationand outputsOK.- Queries are processed in order with no concurrency; output one line per query.
More Stripe problems
- Group Linked Merchant RecordsPHONE SCREEN · Seen Jul 2026
- Invoice / Payment ReconciliationPHONE SCREEN · Seen Jul 2026
- Incident MonitorOA · Seen Jul 2026
- Merchant Fraud Risk ScoringOA · Seen Jul 2026
- WebSocket Load Balancer — Basic Load Balancing (Part 1)OA · Seen Jul 2026
- Rule-Driven Transaction Fraud DetectionOA · PHONE SCREEN · Seen Jul 2026
- Deployment Window SchedulerOA · Seen Jul 2026
- Directly Linked UsersOA · Seen Jun 2026