Peak Concurrent Viewers Across Pinterest Live Shopping Sessions
Last updated: November 29, 2026
Quick Overview
Given viewer sessions for a live shopping stream as half-open intervals [join, leave), return the maximum number of simultaneous viewers and the earliest timestamp at which that peak is reached.
0
0
0 solved
Given viewer sessions for a live shopping stream as half-open intervals [join, leave), return the maximum number of simultaneous viewers and the earliest timestamp at which that peak is reached.
Pinterest has experimented with live and creator-led shopping content, and capacity planning for those streams needs peak concurrency. The interviewer uses this to see whether you know the sweep line trick and can reason precisely about boundary semantics when a leave and a join share a timestamp.
What the Interviewer Expects
- Converts intervals into +1 and -1 events
- Sorts events so a leave at time t is processed before a join at t for half-open intervals
- Tracks the first timestamp the peak is reached
- Handles empty input cleanly
- Compares with a min-heap approach and explains why sorting events is simpler
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
- What if sessions are closed intervals instead of half-open?
- How would you report the full time ranges during which the peak held?
- How would you compute peak concurrency in real time from a stream of join and leave events?
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 session is [join, leave), so a viewer leaving at 5 and another joining at 5 never overlap.
- Output (peak, ts), where ts is the earliest time the peak count is reached. Empty input gives (0, No...
High-Level Design
Turn every session into two events: (join, +1) and (leave, -1). Sort by timestamp, and at equal timestamps process -1 first. Python sorts (5, -1) before (5, 1), which encodes the half-open rule automa...