Transaction Logs — Trigger / Resolve Alerts
Updated
Problem statement
Process error-log rows in nondecreasing timestamp order. Each row is "timestamp,merchant_id,status_code,count".
For each (merchant_id, status_code) pair, maintain the sum of count values in the sliding window (timestamp - windowSize, timestamp]. Before adding the current row, remove earlier rows for that pair whose timestamp is at most timestamp - windowSize; then add the current row's count.
Each pair starts below the threshold. Emit "TRIGGER merchant_id status_code" when its rolling sum crosses from below threshold to at least threshold. Emit "RESOLVE merchant_id status_code" when it crosses from at least the threshold to below it. Emit only on transitions and return events in processing order.
Function
processErrorLogs(logs: String[], windowSize: int, threshold: int) → String[]Examples
Example 1
logs = ["1,m1,E1,2","2,m1,E1,3","3,m2,E1,5","12,m1,E1,1"]windowSize = 10threshold = 5return = ["TRIGGER m1 E1","TRIGGER m2 E1","RESOLVE m1 E1"]m1 reaches 5 at time 2. m2 independently reaches 5 at time 3. At time 12, m1's rows at times 1 and 2 have expired, so its sum becomes 1 and resolves.
Example 2
logs = ["5,shop,declined,7","6,shop,timeout,4","7,shop,declined,1","15,shop,declined,2"]windowSize = 10threshold = 8return = ["TRIGGER shop declined","RESOLVE shop declined"]declined reaches 8 at time 7. At time 15, the count 7 from time 5 expires, leaving 1 + 2 = 3, so the pair resolves. timeout is tracked separately.
Constraints
logsare sorted by nondecreasing timestamp.- Every row is
timestamp,merchant_id,status_code,countwith a non-negative integer count. windowSize > 0andthreshold > 0.- A row at time
t0is active attexactly whent0 > t-windowSize. - Different merchant/status pairs are independent.
More Stripe Phone Screen questions
- Merchant Payout Scheduler, Part 2: Per-Merchant SchedulesPHONE SCREEN · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Business Account KYC Verification — Parts 1–5PHONE SCREEN · Seen Nov 2026
- Render a Task Tree from CSV RowsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Invoice / Payment ReconciliationPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Linked Merchants Within Two HopsPHONE SCREEN · Seen Nov 2026
- Portfolio Valuation, Part 1PHONE SCREEN · Seen Nov 2026
- Account Roles With Parent-User InheritancePHONE SCREEN · Seen Nov 2026
- Merchant Payout Scheduler, Part 3: Hold PeriodsPHONE SCREEN · Seen Nov 2026
- Merchant Payout Scheduler, Part 1PHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Per-Client API Rate LimiterDocker · PHONE SCREEN
- Longest Substring Without Repeating CharactersAngel One · PHONE SCREEN
- Longest Substring Without Repeating CharactersNykaa · PHONE SCREENNykaa interview questions
- Longest Substring Without Repeating CharactersIBM · PHONE SCREENIBM interview questions
- Per-Client Sliding-Window Rate LimiterCVS Health · PHONE SCREEN
- First Unique Character in a StreamAmazon · PHONE SCREEN · ONSITE INTERVIEW
- Longest Substring Without Repeating CharactersTikTok · PHONE SCREENTikTok interview questions
- Sliding-Window Rate LimiterUber · PHONE SCREENUber interview questions
- Find the First Contiguous HaikuFaire · PHONE SCREEN
- Longest Substring Without Repeating CharactersCapgemini · PHONE SCREENCapgemini interview questions
Stripe interview experiences
- Stripe SWE Onsite over Two Days: 1 Experience
- Stripe New Grad SWE Phone Screen and Onsite: 2 Experiences
- Stripe AI Coding Interview, Experienced SWE: 6 Experiences
- Stripe SWE Intern Payout Scheduler Phone Screen: 1 Experience
- Stripe New Grad SWE Onsite and HM Round: 1 Experience
- Stripe Experienced MLE Phone Screens: 1 Experience