Code RoomK highest loads
EasyPrep Room Coding #456

K highest loads

CodingAlgorithms & data structuresEntry–Mid~10 min

Each server in a fleet reports its current CPU load as an integer. Write a function that returns the k highest load values in descending order, so a dashboard can show the busiest machines first. If k is larger than the number of servers, return every load in descending order; if k is zero or the list is empty, return an empty list. Duplicate loads may appear and each report counts separately. Example: loads = [62, 95, 40, 73], k = 2 gives [95, 73].

Implement
top_server_loads(loads: list[int], k: int) → list[int]
Examples
in[[62,95,40,73],2]out[95,73]
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
[[62,95,40,73],2][95,73]not run yetsample