Filter Transaction Logs and Calculate Reliability Metrics
Problem statement
Summarize transaction logs after filtering error codes that should not count toward reliability metrics.
Each log is a comma-separated string:
transaction_id,status_code,latency_msstatus_code is an integer from 100 through 599. A remaining log is successful when its status code is from 200 through 299, inclusive.
Ignore every log whose status code appears in ignoredErrorCodes. For all remaining logs, return:
- the floor of the average latency in milliseconds; and
- the floor of the success rate in basis points, where
10000means100%.
If no logs remain after filtering, return [0,0].
What the interview report shared
The reported internship OA parsed raw transaction logs, filtered error codes, and calculated latency and success metrics. The raw grammar and exact metric definitions were not preserved.
Function
calculateTransactionMetrics(logs: String[], ignoredErrorCodes: int[]) → long[]Examples
Example 1
logs = ["t1,200,120","t2,500,300","t3,404,80","t4,201,100"]ignoredErrorCodes = [404]return = [173,6666]The 404 row is ignored. The remaining latencies total 520, so the floored average is 173. Two of three remaining logs succeed, giving 6666 basis points.
Example 2
logs = ["a,503,9","b,503,11"]ignoredErrorCodes = [503]return = [0,0]Every row is filtered, so both metrics are zero.
Constraints
1 <= logs.length <= 10^5.- Transaction IDs contain lowercase English letters, digits, or underscores.
100 <= status_code <= 599.0 <= latency_ms <= 10^9.0 <= ignoredErrorCodes.length <= 500, with unique values.- Use 64-bit arithmetic for latency totals and rate multiplication.