Perfect.
Below is Day 9 — Extension Round, added on top of the base Day 9 (Ticket Booking with Expiry).
This mirrors a real interview move:
“Okay, your basic solution works. Now let’s extend it.”
This extension is hard but fair, still Level-1+, and extremely common in SDE-1 interviews.
🟢 Day 9 — Extension Round (Seat Lock Ownership + Forced Unlock)
⏱ Extension Rules (Tell Candidate Clearly)
⏰ Time for extension: 25–30 minutes ❌ Do NOT change existing method signatures ❌ Do NOT break existing Day 9 tests ❌ Do NOT add new public classes ✅ You MAY add new private variables ✅ You MAY add new public methods only if specified 🧩 Extension Requirement — Lock Ownership
New Business Requirement
Seat locks are now user-specific.
A seat lock belongs to a user Only the same user can book the seat Only the same user can unlock before expiry Expiry unlock works for any user 🆕 New Concepts Introduced (Still Safe)
🧱 Updated Seat Rules
New Fields (Internal Only)
Seat must now track:
locked_by → user_id (or None) lock_time (already exists) 🔄 Updated Behavior Rules
lock(current_time, user_id)
⚠️ Method signature changes ONLY for this method
def lock(self, current_time: int, user_id: str) -> bool:
Return True if:
Then:
Store locked_by = user_id Else return False.
book(current_time, user_id)
⚠️ Method signature changes ONLY for this method
def book(self, current_time: int, user_id: str) -> bool:
Return True if:
Then:
Else return False.
unlock_if_expired(current_time)
UNCHANGED
Still unlocks regardless of user 🆕 force_unlock(user_id)
NEW METHOD — explicitly allowed
def force_unlock(self, user_id: str) -> bool:
Return True if:
Then:
Else return False.
get_state()
UNCHANGED.
🧠 Expected Candidate Thinking
Candidate must realize:
Booking is authorization + state Force unlock is controlled unlock Must NOT break old expiry logic This tests precision under change.
🧪 Updated solution.py (Candidate Modifies Existing)
class Seat:
def __init__(self, seat_id: str, lock_duration: int):
pass
def lock(self, current_time: int, user_id: str) -> bool:
pass