Shift grants with promotions that start next entry
Track workers clocking in and out, apply promotions starting from the next office entry, and total granted bonuses across overlapping work sessions.
-
Level 1:
add_worker(id, position, rate),register(id, ts)toggles in and out,get_time(id)totals finished sessions. -
Level 2:
top_workers(n, position)as"id(time)", counting time worked in that position. -
Level 3:
promote(id, position, rate, start_ts)takes effect at the first entry at or afterstart_ts;pay(id, start, end). -
Level 4:
add_bonus_window(start, end): time inside any window is paid double (never more, even where windows overlap).
class Office:
def add_worker(self, worker_id, position, rate): ...
def register(self, worker_id, ts): ...
def get_time(self, worker_id): ...
def top_workers(self, n, position): ...
def promote(self, worker_id, position, rate, start_ts): ...
def pay(self, worker_id, start, end): ...
def add_bonus_window(self, start, end): ...
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. Free with an account: one full answer per company.

