Design Check-In System
Instructions
Design a system that tracks employees and the time they spend in the office, built up over two levels:
- Check-ins — add employees and record when they enter or leave the office.
- Reporting — query how long an employee has worked in total.
Interfaces
class CheckInSystem:
def add_employee(self, employee_id: str, position: str, compensation: int) -> bool: ...
def register(self, employee_id: str, timestamp: int) -> str: ...
def get_total_time(self, employee_id: str) -> int: ...
Level 1: Check-Ins
Implement add_employee and register.
add_employee(employee_id, position, compensation)adds the employee along with their position and compensation. ReturnsTrueon success, orFalseifemployee_idalready exists (nothing changes).employee_idandpositioncontain only English letters and spaces.register(employee_id, timestamp)records an office event; calls arrive in strictly increasingtimestamporder. If the employee is currently out of the office, this records a check-in; if currently in, it records a check-out. Returns"registered"on success, or"invalid_request"ifemployee_iddoes not exist.
cs.add_employee("Ashley", "Engineer", 150) # True
cs.add_employee("Ashley", "Manager", 200) # False — ID already exists
cs.register("Ashley", 10) # "registered" — Ashley checks in
cs.register("Ashley", 25) # "registered" — Ashley checks out
cs.register("Walter", 30) # "invalid_request" — unknown employee
Function signature:
class CheckInSystem:
def __init__(self):
pass
def add_employee(self, employee_id: str, position: str, compensation: int) -> bool:
pass
def register(self, employee_id: str, timestamp: int) -> str:
pass
Level 2: Reporting
Add get_total_time(employee_id), which returns the total time the employee has spent in the office, or -1 if employee_id does not exist.
Only completed sessions count: if an employee has checked in but not yet checked out, that open visit is excluded from the total.
cs.add_employee("Ashley", "Engineer", 150) # True
cs.register("Ashley", 10) # check in
cs.register("Ashley", 25) # check out — session of 15
cs.register("Ashley", 40) # check in — still in the office
cs.get_total_time("Ashley") # 15 — the open visit at t=40 is not counted
cs.get_total_time("Walter") # -1
Function signature:
class CheckInSystem:
def __init__(self):
pass
def add_employee(self, employee_id: str, position: str, compensation: int) -> bool:
pass
def register(self, employee_id: str, timestamp: int) -> str:
pass
def get_total_time(self, employee_id: str) -> int:
pass
Anthropic Crash Course
Fullset Newest Anthropic Coding/System Design Questions, Optimal Solutions and Explanations.
Step_1 Matched with a FAANG+ Senior Engineer
Step_2 Fullset Anthropic Coding/System Design Questions
Step_3 Solutions + step by step Explanation
