Code Room
CodingMediumcod-g1332
Subject Log processingLevel Entry–Mid~14 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.