PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates understanding of sequence processing, uniqueness detection, and the use of auxiliary data structures to track previously seen elements when finding non-repeating contiguous subsequences, applied to show names instead of characters.

  • Medium
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Solve non-repeating show substring

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: Medium

Interview Round: Technical Screen

##### Question LeetCode 3. Longest Substring Without Repeating Characters – variant where the elements are show names instead of numbers. https://leetcode.com/problems/longest-substring-without-repeating-characters/description/

Quick Answer: This question evaluates understanding of sequence processing, uniqueness detection, and the use of auxiliary data structures to track previously seen elements when finding non-repeating contiguous subsequences, applied to show names instead of characters.

Netflix logs the sequence of shows a user starts in one binge session as a list of show names. Find the length of the longest contiguous streak of shows in which no show name repeats. This is the classic "Longest Substring Without Repeating Characters" (LeetCode 3), but the elements are full show-name strings instead of single characters. Given an array `shows` of strings, return the length of the longest contiguous subarray that contains no duplicate show name. Example: shows = ["Stranger Things", "The Crown", "Stranger Things", "Wednesday", "Ozark"] The longest non-repeating streak is ["The Crown", "Stranger Things", "Wednesday", "Ozark"] (after the first "Stranger Things" is dropped), so the answer is 4. Use a sliding window with a hash map from show name to its most recent index so the scan runs in O(n).

Constraints

  • 0 <= shows.length <= 5 * 10^4
  • Each show name is a non-empty string; names are compared for exact equality (case-sensitive).
  • The answer is the COUNT of shows in the longest window, not the window's contents.
  • An empty input returns 0.

Examples

Input: (["Stranger Things", "The Crown", "Stranger Things", "Wednesday", "Ozark"],)

Expected Output: 4

Explanation: The window restarts after the repeated "Stranger Things"; the streak ["The Crown", "Stranger Things", "Wednesday", "Ozark"] has 4 distinct shows.

Input: (["Friends", "Friends", "Friends"],)

Expected Output: 1

Explanation: Every show is the same, so the longest distinct streak is a single show.

Input: (["Narcos", "Dark", "Mindhunter", "Sense8"],)

Expected Output: 4

Explanation: All four shows are distinct, so the entire list is one non-repeating streak.

Input: ([],)

Expected Output: 0

Explanation: No shows watched, so the longest streak length is 0.

Input: (["You"],)

Expected Output: 1

Explanation: A single show is trivially a non-repeating streak of length 1.

Input: (["A", "B", "A", "B", "C", "D", "B"],)

Expected Output: 4

Explanation: The window ["A", "B", "C", "D"] starting at the second "A" gives 4 distinct shows before "B" repeats.

Input: (["Lupin", "Money Heist", "Lupin", "Lupin", "Money Heist"],)

Expected Output: 2

Explanation: Consecutive repeats keep collapsing the window; the best is two distinct shows like ["Lupin", "Money Heist"].

Hints

  1. Slide a window [start, i]. Keep a hash map from each show name to the last index where you saw it.
  2. When you encounter a show already inside the current window (its stored index >= start), jump start to one past that previous occurrence instead of shrinking one step at a time.
  3. After updating the window, record max(longest, i - start + 1). Always overwrite the show's stored index to the current i.
Last updated: Jun 25, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Compute Minimum Task Completion Time - Netflix (medium)
  • Solve String Arrays and Row Deduplication - Netflix (medium)
  • Implement Cache, Undo, and DFS - Netflix
  • Implement Streaming Word Counter - Netflix (medium)
  • Implement TTL Cache and Tree Balance Reporting - Netflix (medium)