As reported: Gusto Senior Software Engineer onsite (July 2026), technical round: go through all the logs and output a list of objects with, per response URL, the URL, the number of times it was called, the mean response time and the median response time. Only six URL patterns exist; the expected approach used a regex to extract the fields of each log line and match the URL pattern, a map from pattern to its list of response times, and the statistics computed at the end.
You are given the URL patterns, where {id} stands for one non-empty path segment (e.g. /api/users/{id}), and the logs, one request per line in this format:
<timestamp> <METHOD> <path> <status> <milliseconds>ms
2026-07-01T09:00:00Z GET /api/users/42 200 120ms
For each pattern, in the given order, report the number of requests whose path matches it, the mean and the median response time (the median of an even count is the average of the two middle values). Rules:
- a path matches a pattern if it has the same segments, with any non-empty segment in place of
{id}; a query string (?…) is ignored; - a request counts for the first pattern it matches;
- lines that do not follow the format are skipped; requests matching no pattern are ignored;
- patterns with no requests are left out.
Return a list of UrlStats(pattern, count, mean, median).
Example
patterns = ["/api/users/{id}", "/api/users/{id}/payrolls", "/api/companies/{id}",
"/api/companies/{id}/employees", "/api/payrolls/{id}/submit", "/health"]
logs = [
"2026-07-01T09:00:00Z GET /api/users/42 200 120ms",
"2026-07-01T09:00:01Z GET /api/users/7 200 80ms",
"2026-07-01T09:00:02Z GET /api/users/42/payrolls 200 300ms",
"2026-07-01T09:00:03Z POST /api/payrolls/9/submit 201 950ms",
"2026-07-01T09:00:04Z GET /api/users/7 404 15ms",
"2026-07-01T09:00:05Z GET /health 200 2ms",
"2026-07-01T09:00:06Z GET /api/users/42/payrolls?year=2026 200 340ms",
"garbage line"
]
Output:
/api/users/{id} 3 71.67 80.00
/api/users/{id}/payrolls 2 320.00 320.00
/api/payrolls/{id}/submit 1 950.00 950.00
/health 1 2.00 2.00
Code runner format: two JSON values, one per line: patterns and logs. Implement summarize(patterns, logs); the runner prints one line per result, pattern count mean median, with two decimals (or (none)).