Code RoomSchedule next chores
EasyPrep Room Coding #4813

Schedule next chores

CodingAlgorithms & data structuresEntry–Mid~18 min

A database maintenance daemon holds a set of recurring chores and an operator wants to preview what it will do next. job_names and every_minutes are parallel lists: the chore job_names[i] runs every every_minutes[i] minutes, and every interval is 1 or more. The clock starts at minute 0 and nothing runs at minute 0, so a chore's first run is at its interval, its second at twice its interval, and so on forever. Return the names of the next run_count runs in the order they happen. When two chores land on the same minute, the one listed earlier in job_names goes first, and that rule settles every collision, so one answer is correct. A chore appears once per run, so names repeat, and two chores may share a name. Return an empty list when run_count is 0 or less, and when no chores are given.

Implement
upcoming_job_runs(job_names: list[str], every_minutes: list[int], run_count: int) → list[str]
Examples
in[["vacuum","reindex"],[2,3],6]out["vacuum","reindex","vacuum","vacuum","reindex","vacuum"]
in[["snapshot","compact","verify"],[15,10,15],5]out["compact","snapshot","verify","compact","snapshot"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 18 min
InputExpectedGot
[["vacuum","reindex"],[2,3],6]["vacuum","reindex","vacuum","vacuum","reindex","vacuum"]not run yetsample
[["snapshot","compact","verify"],[15,10,15],5]["compact","snapshot","verify","compact","snapshot"]not run yetsample