Detect First Moment an Account Exceeds Its Concurrent Stream Limit

Last updated: November 29, 2026

Quick Overview

Given playback sessions as (account_id, start, end) half-open intervals and each account's plan limit on simultaneous streams, return for every violating account the earliest time its number of live streams exceeds the limit.

Netflix
Coding & Algorithms
Software Engineer
Netflix
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given playback sessions as (account_id, start, end) half-open intervals and each account's plan limit on simultaneous streams, return for every violating account the earliest time its number of live streams exceeds the limit.

Netflix plans cap how many screens can stream at once, and the playback licensing path has to enforce that cap. Interviewers use this sweep line problem to see whether a candidate handles boundary semantics (a stream ending exactly when another begins) and groups work per account cleanly.

What the Interviewer Expects
  • Pin down half-open interval semantics before coding
  • Use a sweep over start and end events instead of pairwise overlap checks
  • Order ends before starts at equal timestamps and justify it
  • Process each account independently and stop at the first violation
  • State complexity as O(n log n) overall
Key Topics to Cover
sweep line
interval overlap
event sorting
hash maps
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 report the full time ranges of violation instead of the first moment?
  • How would this work as a live check when a new play request arrives?
  • What changes if sessions can be missing an end time because a device went offline?
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 covers [start, end). A stream that ends at t and one that starts at t do not overlap. For each account, find the earliest t where live streams > limit. Accounts that never exceed the limi...

High-Level Design

Turn every session into two events: (start, +1) and (end, -1). Group by account, sort each group by time, and break ties by putting -1 before +1 so back-to-back sessions never look concurrent. Walk th...


Submit Your Answer
Markdown supported