Schedule next chores

Write codeEasy18 min

Your task

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.

Examples

upcoming_job_runs(job_names: list[str], every_minutes: list[int], run_count: int) -> list[str]
Example 1
Inputupcoming_job_runs(["vacuum", "reindex"], [2, 3], 6)
Output["vacuum", "reindex", "vacuum", "vacuum", "reindex", "vacuum"]
Example 2
Inputupcoming_job_runs(["snapshot", "compact", "verify"], [15, 10, 15], 5)
Output["compact", "snapshot", "verify", "compact", "snapshot"]