Filter Transaction Logs and Calculate Reliability Metrics
Updated
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 average latency in milliseconds, rounded down to an integer; and
- the success rate in basis points, rounded down to an integer, where
10000means100%.
If no logs remain after filtering, return [0,0].
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.
More Stripe Online Assessment questions
- Split Tender Part 4 - RefundsOA · PHONE SCREEN · Seen Nov 2026
- Split Tender Part 3 - SurchargesOA · Seen Nov 2026
- Split Tender Part 2 - Expiration DatesOA · Seen Nov 2026
- Split Tender Part 1 - Basic Split TenderingOA · Seen Nov 2026
- Asynchronous Event ProcessingOA · Seen Nov 2026
- Subscription and Usage-Based Billing CalculatorOA · Seen Nov 2026
- Payment Partner RoutingOA · Seen Nov 2026
- Financial Account LedgerOA · PHONE SCREEN · Seen Nov 2026
- Maximum Game Score with Fixed Forward JumpsOA · Seen Nov 2026
- Reliable LLM Call with Independent Retry BudgetsOA · Seen Nov 2026
Similar questions at other companies
- Cheating CodemakerJane Street · OAJane Street interview questions
- Aggregate Paginated Project Run RecordsReplit · OA
- Project JSON Fields into a Target FormatBooking.com · PHONE SCREEN
- Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
- Most Frequent Call Path in Interleaved LogsRoblox · ONSITE INTERVIEWRoblox interview questions
- Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
- Credit Card Command ProcessorChime · PHONE SCREEN
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Branch with the Most FilesCapital One · OACapital One interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions