Pop-up Clinic Check-in Table
Also known as: Time-Travel Table with Partial Updates
Pop-up Clinic Check-in Table A time-travel table for tracking patient check-ins. Fields are stored as "key:value" pairs separated by commas. - insert(ts, rowId, fields): Insert new row - update(ts, rowId, fields): Partial update (merge fields) - delete(ts, rowId): Delete row at timestamp - get(ts, rowId): Get current row at timestamp - getAt(ts, rowId): Time-travel query - selectAt(ts, filter): Select rows matching filter at timestamp
You're building a check-in system where records can be queried at any point in time—even after updates or deletions. The challenge is handling partial updates and soft deletes while keeping history intact. Interviewers use this to see if you can model temporal state cleanly.
Examples
You write
ClinicTable: insert(timestamp: int, row_id: str, fields: str), update(timestamp: int, row_id: str, fields: str), delete(timestamp: int, row_id: str), get(timestamp: int, row_id: str), get_at(timestamp: int, row_id: str), select_at(timestamp: int, filter_str: str)
Example 1
- Input
- insert(1,"p1",{name:"Alice"}), get(1,"p1")→{name:"Alice"}
- returns
- ["{name:Alice}"]
Example 2
- Input
- Multiple patients
- returns
- ["{name:Alice}", "{name:Bob}"]
The pattern behind it
Design
I reach for it when
- The statement describes a class with methods, not one function.
- Each method needs to be fast, and the structure decides how fast.
Say this before you type. Say each method, the cost you want from it, and the structure that earns that cost.
All 27 Design problems
Meet Coco
Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit. The editor and Run stay open without an account. Anyone can open the editor and run their code.
Each locked part opens in the editor once the part before it passes.