Find the First Illegal Status Transition for Each Loan
Last updated: November 29, 2026
Quick Overview
Given an unordered log of (timestamp, loan_id, new_status) events and a table of allowed status transitions, return for each loan the first event that is not a legal transition from its current status.
Upstart
November 29, 20260
0
0 solved
Given an unordered log of (timestamp, loan_id, new_status) events and a table of allowed status transitions, return for each loan the first event that is not a legal transition from its current status.
A loan at Upstart moves from application through approval, funding, servicing states and payoff or charge-off, and bad transitions in event logs cause real reporting errors. The phone screen uses this state machine problem to check clean modeling, sorting by time, and careful handling of the initial state.
What the Interviewer Expects
- Model allowed transitions as a dictionary of sets
- Sort events by timestamp before replay
- Treat APPLIED as the only legal first state
- Record only the first violation per loan
- Keep processing other loans after a violation
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- Two events for the same loan share a timestamp. How do you break ties?
- Should the state advance after an illegal event? Argue both sides.
- How would you run this over billions of events in a batch job?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
A loan with no prior state may only move to APPLIED. Terminal states (DECLINED, WITHDRAWN, EXPIRED, PAID_OFF, CHARGED_OFF) allow nothing further. Output maps loan id to `(timestamp, from_status, to_st...
High-Level Design
Sort the log by timestamp (then loan id for stable ties), replay it while holding each loan's current status, and check each event against the allowed set. Once a loan has a recorded violation, ignore...