Find Peak Concurrent Active Virtual Card Numbers
Last updated: November 29, 2026
Quick Overview
Each virtual card number has a creation time and an expiry time and is active on the half-open interval [create, expire). Return the maximum number of virtual cards active at the same moment and the earliest time that peak begins.
Capital One
November 29, 20260
0
0 solved
Each virtual card number has a creation time and an expiry time and is active on the half-open interval [create, expire). Return the maximum number of virtual cards active at the same moment and the earliest time that peak begins.
Capital One issues virtual card numbers through Eno so customers can shop online without exposing their real card number. A capacity question like this appears in technical screens to test sweep-line thinking and, specifically, whether you handle the tie at equal timestamps correctly for half-open intervals.
What the Interviewer Expects
- Convert intervals into +1 and -1 events
- Sort with ends before starts at the same timestamp
- Track the running count and the first time the maximum is reached
- Skip zero-length or invalid intervals
- Explain why the tie-break matters
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 the full time ranges where the peak holds, not just the start?
- How would you answer many queries of the form how many cards were active at time t?
- What if intervals arrive as a stream and you need the peak so far?
- How would you shard this across merchants when the data is too large for one machine?
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: list of
(create_ts, expire_ts)pairs, integer timestamps. - A card is active from
createup to but not includingexpire, so a card expiring at 5 and one created at 5 are never active to...
High-Level Design
Turn each interval into two events: (create, +1) and (expire, -1). Sort by time, and at equal times put -1 before +1; sorting on the tuple (time, delta) does this for free because -1 sorts b...