Code RoomScan schedule with gaps
EasyPrep Room Coding #473

Scan schedule with gaps

CodingAlgorithms & data structuresEntry–Mid~13 min

An imaging suite runs scans back to back in the exact order they were booked. Each scan occupies one time slot. The machine needs `gap` idle slots between two scans of the same type (different types can run back to back); the schedule waits, leaving slots empty, whenever the rule requires. Given the ordered list of scan types and the integer gap, return the total number of slots from the start until the last scan finishes. Example: scans = ["MRI", "MRI"], gap = 2 gives 4 — the second MRI waits out slots 1 and 2 and runs in slot 3.

Implement
schedule_length(scans: list[str], gap: int) → int
Examples
in[["MRI","MRI"],2]out4
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 13 min
InputExpectedGot
[["MRI","MRI"],2]4not run yetsample