Account Scheduler - Availability and Acquire
Updated
Problem 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"]Account 1 is locked until 10, so at t=8 it is not available -> false. Account 2 locked until 5, at t=8 available -> true. Account 3 locked until 0, at t=1 available -> true. Account 4 locked until 20, at t=21 available -> 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"]At t=1 account 3 (locked until 0) is available -> true. ACQUIRE 3 for duration 5 at t=1 locks it until 1+5=6 -> OK. At t=4, 4 < 6 so it is not available -> false. At t=6, 6 >= 6 so it is available again -> 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 Onsite Interview questions
- Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Parse Boolean Rule ExpressionsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Transaction Rule Expression EvaluatorONSITE INTERVIEW · Seen Oct 2026
- Evaluate Ordered Action RulesPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- WebSocket Load Balancer — Parts 1–5OA · ONSITE INTERVIEW · Seen Sep 2026
- Rule-Driven Transaction Fraud DetectionPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen May 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen May 2026
- Account Balance Manager Part 1 - Calculate TotalsONSITE INTERVIEW · Seen May 2026
Similar questions at other companies
- In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
- In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
- In-Memory Directory and File OperationsSquarepoint Capital · ONSITE INTERVIEWSquarepoint Capital interview questions
- In-Memory Spreadsheet ValuesRippling · PHONE SCREEN · ONSITE INTERVIEWRippling interview questions
- Feature Flag Evaluation EngineCresta · ONSITE INTERVIEWCresta interview questions
- Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One interview questions
- Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
- Parcel Event TrackingAirbnb · OAAirbnb interview questions
- Reference-Counted Deduplicating File SystemCitadel · PHONE SCREENCitadel interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions