PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/Netflix

Return the longest contiguous subarray with all distinct values

Last updated: Mar 29, 2026

Quick Overview

This question evaluates a candidate's understanding of array-processing algorithms, duplicate detection, and maintaining state to identify the longest contiguous subarray with distinct values, assessing algorithmic thinking and data structure usage.

  • medium
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Return the longest contiguous subarray with all distinct values

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an array `shows` of integers, return the **longest contiguous subarray** in which all values are **distinct** (no repeats within the subarray). ### Function signature - Input: `shows: List[int]` - Output: `List[int]` (the subarray values) ### Tie-breaking If multiple subarrays have the same maximum length, return the one with the **smallest starting index**. ### Examples - `shows = [1, 2, 3, 2, 4]` → `[1, 2, 3]` - `shows = [5, 5, 5]` → `[5]` - `shows = []` → `[]` ### Constraints - Target `O(n)` time. - Extra space up to `O(n)` is allowed.

Quick Answer: This question evaluates a candidate's understanding of array-processing algorithms, duplicate detection, and maintaining state to identify the longest contiguous subarray with distinct values, assessing algorithmic thinking and data structure usage.

Related Interview 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)
Netflix logo
Netflix
Jan 22, 2026, 12:00 AM
Software Engineer
Technical Screen
Coding & Algorithms
12
0
Loading...

Given an array shows of integers, return the longest contiguous subarray in which all values are distinct (no repeats within the subarray).

Function signature

  • Input: shows: List[int]
  • Output: List[int] (the subarray values)

Tie-breaking

If multiple subarrays have the same maximum length, return the one with the smallest starting index.

Examples

  • shows = [1, 2, 3, 2, 4] → [1, 2, 3]
  • shows = [5, 5, 5] → [5]
  • shows = [] → []

Constraints

  • Target O(n) time.
  • Extra space up to O(n) is allowed.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More Netflix•More Software Engineer•Netflix Software Engineer•Netflix Coding & Algorithms•Software Engineer Coding & Algorithms
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
  • Compare Platforms
  • Discord Community

Support

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

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.