Parse and bucket latency logs
Given access log lines ts method path status latency_ms, return p50, p95 and p99 latency per path per fixed window. Count only 2xx.
Statement
You're given access log lines in the form ts method path status latency_ms, where ts is a Unix timestamp in seconds. Return the p50, p95 and p99 latency for each path in each fixed window of window_s seconds.
Only count 2xx responses. Skip lines that don't have exactly five fields. Use the nearest-rank percentile.
Examples
window_s = 60
1700000003 GET /api 200 41
1700000017 GET /api 200 88
1700000059 GET /api 500 12
1700000061 GET /api 200 90
→ {(1699999980, "/api"): {50: 41, 95: 88, 99: 88},
(1700000040, "/api"): {50: 90, 95: 90, 99: 90}}Constraints
Up to 10⁶ lines and 10⁴ distinct paths. Lines may be out of order by up to 30 s. Must finish in 3 s on one core.
Free to try · sign in to save your attemptSolve it in the editor with visible tests
Open in the app