Peak Concurrent Viewers Across Overlapping Livestream Sessions

Last updated: November 29, 2026

Quick Overview

Given viewer sessions as half-open [join, leave) intervals for one livestream show, return the maximum number of simultaneous viewers and the earliest time that peak is reached.

Whatnot
Coding & Algorithms
Data Engineer
Whatnot
November 29, 2026
Data Engineer
Phone Screen
Coding & Algorithms
Easy

0

0

0 solved


Given viewer sessions as half-open [join, leave) intervals for one livestream show, return the maximum number of simultaneous viewers and the earliest time that peak is reached.

Concurrent viewers is a key health metric for a Whatnot show, both for sellers and for ranking shows in the feed. This screen question checks whether you reach for a sweep line and get the boundary rule right at equal timestamps.

What the Interviewer Expects
  • Turn each session into a +1 and a -1 event
  • Sort so leaves process before joins at the same time
  • Track the running count and the time the max first appears
  • Drop zero-length or malformed sessions
  • State the complexity clearly
Key Topics to Cover
sweep line
intervals
sorting
event counting
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you compute the peak per minute bucket for a chart?
  • How would you do this over a stream of join and leave events that never ends?
  • What if the same viewer reconnects several times and you want unique viewers?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Each session (join, leave) is half-open, so a viewer leaving at 10 and one joining at 10 never overlap. Return (peak, time); with no sessions return (0, None). Sessions with leave <= join are ...

High-Level Design

Emit (join, +1) and (leave, -1) events, sort, and walk them keeping a running count. Sorting tuples puts -1 before +1 at the same timestamp, which is exactly the half-open rule. Record the tim...


Submit Your Answer
Markdown supported

Related Questions