Longest Binge Streak Allowing at Most K Skipped Episodes
Last updated: November 29, 2026
Quick Overview
Given a list of episodes in order where 1 means the viewer watched it and 0 means they skipped it, return the length and index range of the longest contiguous run containing at most k skipped episodes.
Disney
November 29, 20260
0
0 solved
Given a list of episodes in order where 1 means the viewer watched it and 0 means they skipped it, return the length and index range of the longest contiguous run containing at most k skipped episodes.
A phone-screen problem in the style of Disney+ engagement teams, who study how viewers move through a season of a series. The interviewer wants a sliding window with a clear invariant rather than nested loops.
What the Interviewer Expects
- Recognize a variable-size sliding window
- State the invariant: the window holds at most k zeros
- Shrink from the left only when the invariant breaks
- Return both length and range
- Justify O(n) time with amortized pointer movement
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 each episode has a runtime and you want the longest streak by minutes?
- How would you compute this for every viewer of a series in a batch job?
- What if k must be chosen so the streak covers at least 80% of the season?
- How do you handle a viewer who rewatches episodes out of order?
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: a list of 0s and 1s and an integer k >= 0. Output: the maximum window length that contains at most k zeros, plus (start, end) inclusive indices of the first such window. If no window qual...
High-Level Design
Brute force checks all O(n^2) windows. Instead, grow the right pointer one step at a time and count zeros in the window. When the count exceeds k, advance the left pointer until it drops back to k...