Summarize Trading Pair Outages Within a Reporting Day
Last updated: November 29, 2026
Quick Overview
Given outage intervals for many trading pairs, compute the total time in a reporting day when at least one pair was down and the longest stretch when every pair was healthy.
Coinbase
November 29, 20260
0
0 solved
Given outage intervals for many trading pairs, compute the total time in a reporting day when at least one pair was down and the longest stretch when every pair was healthy.
Coinbase publishes incident and uptime data for its markets, and on-call engineers write this kind of rollup for status reports. The interviewer looks for interval clipping, sorting and merging, and correct handling of gaps at the day's edges.
What the Interviewer Expects
- Clip intervals to the reporting window and drop those fully outside
- Sort by start and merge overlapping or touching intervals
- Compute downtime as the sum of merged lengths
- Compute the longest healthy gap including before the first and after the last outage
- Discuss half-open interval conventions
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you return downtime per pair and the pair with the worst availability?
- How would you answer many day queries over a long history quickly?
- What if intervals stream in and you must keep the merged set updated?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Input: (market, start, end) half-open intervals in minutes, plus day_start and day_end. Output: (down_minutes, longest_healthy_stretch) within the day. Which market is down does not matter for...
High-Level Design
Clip every interval to [day_start, day_end) and discard empty ones. Sort by start and merge: if the next start is at or before the current end, extend the end; otherwise begin a new block. Downtime ...