Code RoomSlow endpoint paths
MediumPrep Room Coding #520

Slow endpoint paths

CodingAlgorithms & data structuresEntry–Mid~14 min

A latency log has one line per request: "<path> <latency_ms>" with integer latency. An endpoint is flagged slow when its AVERAGE latency across all its requests is at least the threshold. Return the flagged paths sorted alphabetically. Do the comparison with integers only: an average sum/count >= threshold is exactly the condition sum >= threshold * count, which avoids float rounding entirely. Return an empty list when nothing is flagged or the log is empty.

Implement
slow_endpoints(lines: list[str], threshold: int) → list[str]
Examples
in[["/a 100","/a 300","/b 100"],200]out["/a"]
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 14 min
InputExpectedGot
[["/a 100","/a 300","/b 100"],200]["/a"]not run yetsample