PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates array-manipulation skills and the ability to identify contiguous runs of equal values, emphasizing algorithmic efficiency and edge-case handling within the Coding & Algorithms domain. It is commonly asked to assess practical application of linear-time, constant-space processing and attention to implementation details rather than purely theoretical concepts.

  • medium
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Find longest run of identical consecutive shows

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

Given an array `shows` of integers, find the **maximum length of a contiguous run** where all values are equal. ### Function signature - Input: `shows: List[int]` - Output: `int` ### Examples - `shows = [7, 7, 2, 2, 2, 7]` → `3` (the run `[2,2,2]`) - `shows = []` → `0` ### Constraints - Aim for an `O(n)` time solution with `O(1)` extra space.

Quick Answer: This question evaluates array-manipulation skills and the ability to identify contiguous runs of equal values, emphasizing algorithmic efficiency and edge-case handling within the Coding & Algorithms domain. It is commonly asked to assess practical application of linear-time, constant-space processing and attention to implementation details rather than purely theoretical concepts.

Given an array of integers `shows`, return the maximum length of a contiguous run where all values are equal. A run must consist of consecutive elements in the array. If the array is empty, return `0`. For example, in `[7, 7, 2, 2, 2, 7]`, the longest contiguous run of identical values is `[2, 2, 2]`, so the answer is `3`.

Constraints

  • 0 <= len(shows) <= 100000
  • -1000000000 <= shows[i] <= 1000000000
  • Aim for O(n) time and O(1) extra space

Examples

Input: ([7, 7, 2, 2, 2, 7],)

Expected Output: 3

Explanation: The longest contiguous block of equal values is `[2, 2, 2]`, which has length 3.

Input: ([],)

Expected Output: 0

Explanation: An empty list has no runs, so the answer is 0.

Input: ([5],)

Expected Output: 1

Explanation: A single element forms a run of length 1.

Input: ([1, 1, 1, 1],)

Expected Output: 4

Explanation: All elements are the same, so the entire array is one run of length 4.

Input: ([1, 2, 3, 4],)

Expected Output: 1

Explanation: No two consecutive elements are equal, so the longest run length is 1.

Input: ([3, 2, 2, 3, 3, 3, 2],)

Expected Output: 3

Explanation: The longest run is `[3, 3, 3]`, which has length 3.

Input: ([-1, -1, -1, 2, 2, -1],)

Expected Output: 3

Explanation: The longest run is `[-1, -1, -1]`, which has length 3.

Hints

  1. Compare each element with the previous one to see whether the current run continues or resets.
  2. Keep two counters: one for the current run length and one for the maximum run length seen so far.
Last updated: May 4, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ 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.

Related Coding Questions

  • Implement Cache, Undo, and DFS - Netflix
  • Implement Streaming Word Counter - Netflix (medium)
  • Implement TTL Cache and Tree Balance Reporting - Netflix (medium)
  • Implement ordering and undo executor - Netflix (medium)
  • Implement Caches, Undo, and Traversal - Netflix