Find Peak Concurrent Active Virtual Cards From Validity Windows
Last updated: November 29, 2026
Quick Overview
Each virtual card is active on a half-open interval [start, end). Return the maximum number of cards active at the same moment and the earliest time that peak is reached.
Ramp
November 29, 20260
0
0 solved
Each virtual card is active on a half-open interval [start, end). Return the maximum number of cards active at the same moment and the earliest time that peak is reached.
Ramp lets companies spin up short-lived virtual cards for vendors and one-off purchases, and capacity planning for card issuing partners depends on peak concurrent cards. The online assessment style is a clean sweep-line problem where the interviewer checks the tie-break at equal times.
What the Interviewer Expects
- Converts intervals to +1 and -1 events
- Sorts so ends process before starts at the same time for half-open intervals
- Tracks the running count and the time the maximum is first reached
- Ignores empty intervals where start equals end
- States O(n log n) complexity
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 every maximal time range at the peak, not just its start?
- If timestamps are small integers, can you avoid sorting?
- How would you answer 'active count at time t' for many queries?
- What changes if intervals are closed?
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 is a list of (start, end) with the card active for start <= t < end. Output (peak, earliest_time); for no cards return (0, None)....
High-Level Design
Turn each interval into two events, (start, +1) and (end, -1), and sort. Sorting tuples puts -1 before +1 at the same timestamp, which is exactly the half-open rule: a card ending at 5 is gone...