PracHub
QuestionsCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates a candidate's ability to design and analyze efficient algorithms for detecting longest consecutive incrementing sequences in unsorted integer arrays, testing understanding of appropriate data structures and time/space complexity trade-offs.

  • medium
  • Netflix
  • Coding & Algorithms
  • Data Scientist

Identify Longest Consecutive Incrementing Watch-Time Sequence

Company: Netflix

Role: Data Scientist

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

##### Scenario A streaming platform records daily minutes watched per user and wants to identify engagement streaks. ##### Question Given an unsorted integer array representing daily watch-time deltas, return the length of the longest sequence of consecutive, incrementing integers (e.g., 1,2,3…). Explain the algorithm and analyze complexity. ##### Hints Think hash-set to achieve O(n) time and avoid re-scanning sequences.

Quick Answer: This question evaluates a candidate's ability to design and analyze efficient algorithms for detecting longest consecutive incrementing sequences in unsorted integer arrays, testing understanding of appropriate data structures and time/space complexity trade-offs.

Given an unsorted integer array deltas representing daily watch-time changes, return the length of the longest sequence of values that are consecutive and strictly increment by 1 (k, k+1, k+2, ...). The sequence is formed from values only; indices and original order do not matter. Duplicates do not extend a sequence. If the array is empty, return 0.

Constraints

  • 0 <= len(deltas) <= 200000
  • -10^9 <= deltas[i] <= 10^9
  • Duplicates may appear and should be treated as a single value for sequence building
  • Expected average time: O(n) using hashing
  • Auxiliary space: O(n)

Hints

  1. Insert all numbers into a hash set for O(1) average lookups.
  2. Only start counting from numbers x where x-1 is not in the set (start of a run).
  3. From each start, incrementally check x+1, x+2, ... to count the run length.
  4. Duplicates are naturally handled by the set and do not extend runs.
Last updated: Mar 29, 2026

Loading coding console...

PracHub

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

Product

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

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

  • Simulate a TTL Cache with LRU Eviction - Netflix (medium)
  • Compute Minimum Task Completion Time - Netflix (medium)
  • Solve String Arrays and Row Deduplication - Netflix (medium)
  • Implement Cache, Undo, and DFS - Netflix (medium)
  • Implement Streaming Word Counter - Netflix (medium)