Code RoomTwo-track slot fill
MediumPrep Room Coding #428

Two-track slot fill

CodingAlgorithms & data structuresEntry–Mid~15 min

A radio show has a slot of exactly slot seconds left and wants to fill it with two tracks whose durations (in seconds) add up to slot exactly. The two tracks must come from different positions in the durations list, though their durations may be equal. Return the chosen pair as [shorter, longer] in ascending order. If several pairs fit, return the one whose shorter duration is smallest; if no pair fits, return an empty list. For example, durations [180, 240, 120, 300] with slot 420 gives [120, 300] rather than [180, 240].

Implement
duet_fill(durations: list[int], slot: int) → list[int]
Examples
in[[180,240,120,300],420]out[120,300]
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 15 min
InputExpectedGot
[[180,240,120,300],420][120,300]not run yetsample