Total Hours Covered by Overlapping Super Sale Campaigns
Last updated: November 29, 2026
Quick Overview
Rakuten runs many overlapping campaigns during Super Sale. Given campaigns as half-open hour intervals [start, end), return the total number of hours during which at least one campaign is live, and the maximum number running at once.
Rakuten
November 29, 20260
0
0 solved
Rakuten runs many overlapping campaigns during Super Sale. Given campaigns as half-open hour intervals [start, end), return the total number of hours during which at least one campaign is live, and the maximum number running at once.
Rakuten Super Sale and Marathon events stack shop campaigns, point multipliers and coupons on top of each other, and ops teams care about both total coverage and peak overlap. This warm-up checks interval merging and a sweep line in the same breath.
What the Interviewer Expects
- Sort by start time before merging
- Treat touching intervals correctly under half-open semantics
- Use a sweep line with end events before start events for peak count
- Keep both functions O(n log n)
- Mention empty input
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
- Return the actual time window where the peak occurs.
- Campaigns now carry a point multiplier. Return the hours where the summed multiplier exceeds 10x.
- Intervals arrive online. Which data structure keeps coverage 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
Each campaign is (start, end) in integer hours with start < end. Half-open means [8,10) and [10,12) touch but never overlap. Return total covered hours, and separately the peak number of simul...
High-Level Design
Coverage: sort by start and merge. Keep a current block; if the next interval starts at or before the block end, extend the block, otherwise add the block length to the total and start a new one. Touc...