Code RoomK shortest waits
EasyPrep Room Coding #457

K shortest waits

CodingAlgorithms & data structuresEntry–Mid~10 min

A hospital triage board tracks how long each waiting patient has been in the queue, in minutes. The charge nurse wants the k shortest waits, in ascending order, to spot who was seen fastest during an audit. Write a function that returns those k values. If k exceeds the number of patients, return all waits in ascending order; if k is zero, return an empty list. Ties are fine — repeated wait times each count. Example: waits = [30, 5, 12, 48], k = 2 gives [5, 12].

Implement
shortest_wait_times(waits: list[int], k: int) → list[int]
Examples
in[[30,5,12,48],2]out[5,12]
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 10 min
InputExpectedGot
[[30,5,12,48],2][5,12]not run yetsample