PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This multi-part question evaluates array and string manipulation skills, deduplication logic and pairwise character comparison, as well as the ability to reason about algorithmic complexity and data-structure choices; it belongs to the Coding & Algorithms domain.

  • medium
  • Netflix
  • Coding & Algorithms
  • Software Engineer

Solve String Arrays and Row Deduplication

Company: Netflix

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Technical Screen

You are given the following independent coding tasks. For each task, write clean production-quality code, handle edge cases, and state the time and space complexity. 1. **Longest run of equal strings** - Input: an array of strings `arr`. - Output: the longest contiguous subarray in which every string is the same. - If there are multiple valid answers with the same maximum length, return any one of them, or return its start and end indices if you prefer. - Example: for `['a', 'a', 'b', 'b', 'b', 'a']`, the answer is `['b', 'b', 'b']`. 2. **Longest subarray without duplicate strings** - Input: an array of strings `arr`. - Output: the longest contiguous subarray containing no repeated string. - If there are multiple valid answers with the same maximum length, return any one of them, or return its start and end indices. - Example: for `['a', 'b', 'c', 'a', 'd']`, one answer is `['b', 'c', 'a', 'd']`. 3. **Find string pairs with no shared characters** - Input: an array of strings `words`. - Output: all index pairs `[i, j]` where `i < j` and `words[i]` and `words[j]` do not share any character. - Example: for `['a', 'ab', 'b']`, the output is `[[0, 2]]`, because `'a'` and `'b'` have no common characters. 4. **Deduplicate items in content rows** - You are given a home page layout represented as a list of rows. Each row contains a list of movie IDs or content IDs. - For each row that should be deduplicated, remove duplicate IDs while preserving the original order. - A row has a deduplication threshold. Once the deduplicated portion of that row has reached the threshold, any remaining items in that row may be left as-is, even if they are duplicates. - Follow-up 1: The threshold is dynamic and may be `6` or any other integer, potentially different per row. - Follow-up 2: Only the first `N` rows need deduplication; rows after the first `N` rows may contain duplicates. - Follow-up 3: Some special rows are exempt from deduplication based on a condition or row type. - Design and implement a function that supports the base case and the follow-ups. Include representative test cases.

Quick Answer: This multi-part question evaluates array and string manipulation skills, deduplication logic and pairwise character comparison, as well as the ability to reason about algorithmic complexity and data-structure choices; it belongs to the Coding & Algorithms domain.

Part 1: Longest Run of Equal Strings

Given an array of strings `arr`, return the longest contiguous subarray in which every string is identical. If multiple runs have the same maximum length, return the earliest such run so the result is deterministic. Return the actual subarray, not just its length.

Constraints

  • 0 <= len(arr) <= 200000
  • Each element of `arr` is a string and may be empty
  • Total number of characters across all strings is at most 1000000

Examples

Input: ['a', 'a', 'b', 'b', 'b', 'a']

Expected Output: ['b', 'b', 'b']

Explanation: The longest contiguous block of equal strings is the run of three `'b'` values.

Input: ['x', 'y', 'y', 'z', 'z']

Expected Output: ['y', 'y']

Explanation: There are two longest runs of length 2: `['y', 'y']` and `['z', 'z']`. Return the earliest one.

Input: ['solo']

Expected Output: ['solo']

Explanation: A single-element array has a longest run of length 1.

Input: []

Expected Output: []

Explanation: Empty input should return an empty list.

Hints

  1. Scan from left to right and keep track of where the current run started.
  2. Whenever the value changes, compare the finished run against the best run seen so far.

Part 2: Longest Subarray Without Duplicate Strings

Given an array of strings `arr`, return the longest contiguous subarray that contains no repeated string. If multiple longest subarrays exist, return the earliest one. Return the actual subarray.

Constraints

  • 0 <= len(arr) <= 200000
  • Each element of `arr` is a string and may be empty
  • Total number of characters across all strings is at most 1000000

Examples

Input: ['a', 'b', 'c', 'a', 'd']

Expected Output: ['b', 'c', 'a', 'd']

Explanation: The longest window with all unique strings is from index 1 to 4.

Input: ['x', 'y', 'z']

Expected Output: ['x', 'y', 'z']

Explanation: All strings are already distinct, so the whole array is the answer.

Input: ['x', 'x', 'x']

Expected Output: ['x']

Explanation: Every valid subarray has length 1. Return the earliest one.

Input: []

Expected Output: []

Explanation: Empty input has no subarray.

Hints

  1. A sliding window works well when you need a longest contiguous segment with a constraint.
  2. Store the last seen index of each string so you can move the left side of the window efficiently.

Part 3: Find String Pairs With No Shared Characters

Given an array of strings `words`, return all index pairs `[i, j]` such that `i < j` and `words[i]` and `words[j]` share no character in common. Treat each word as a set of characters, so repeated letters inside a word do not change the result. Return pairs in ascending order by `i`, then by `j`.

Constraints

  • 0 <= len(words) <= 2000
  • 0 <= len(words[i]) <= 1000
  • The sum of all word lengths is at most 200000

Examples

Input: ['a', 'ab', 'b']

Expected Output: [[0, 2]]

Explanation: `'a'` and `'b'` share no character, but `'ab'` overlaps with both.

Input: ['abc', 'de', 'fa']

Expected Output: [[0, 1], [1, 2]]

Explanation: `'abc'` and `'de'` are disjoint, `'de'` and `'fa'` are disjoint, but `'abc'` and `'fa'` both contain `'a'`.

Input: ['', 'ab', 'c']

Expected Output: [[0, 1], [0, 2], [1, 2]]

Explanation: The empty string shares no characters with any word, and `'ab'` and `'c'` are also disjoint.

Input: []

Expected Output: []

Explanation: No words means no valid pairs.

Hints

  1. Precompute a character set for each word so you do not rebuild it for every pair.
  2. Two words are valid together exactly when their character sets are disjoint.

Part 4: Deduplicate Items in Content Rows

You are given rows of content IDs. For each eligible row, remove duplicates while preserving the original order, but only until that row's deduplicated output reaches its threshold. After the threshold is reached, append the rest of the original row unchanged. A row is eligible for deduplication only if its index is within the first `first_n` rows and it is not marked exempt. If a row's threshold is negative, deduplicate the whole row. If a row's threshold is `0`, leave it unchanged. Return the processed rows as lists of IDs. The reference Python solution accepts either a single tuple `(rows, thresholds, first_n, exempt_rows)` or the four arguments separately.

Constraints

  • 0 <= len(rows) <= 10000
  • len(rows) == len(thresholds) == len(exempt_rows)
  • The total number of IDs across all rows is at most 200000

Examples

Input: ([[1, 2, 1, 3, 2, 4], [5, 5, 6], [7, 8, 7]], [3, -1, 2], 2, [False, False, False])

Expected Output: [[1, 2, 3, 2, 4], [5, 6], [7, 8, 7]]

Explanation: Row 0 deduplicates only until 3 unique items are produced, row 1 is fully deduplicated because its threshold is negative, and row 2 is unchanged because it is beyond the first 2 rows.

Input: ([[1, 1, 2], [3, 3, 4, 4]], [10, 10], 2, [True, False])

Expected Output: [[1, 1, 2], [3, 4]]

Explanation: The first row is exempt, so it stays unchanged. The second row is fully deduplicated.

Input: ([[1, 2, 1, 2]], [0], 1, [False])

Expected Output: [[1, 2, 1, 2]]

Explanation: A threshold of 0 means the row may be left entirely as-is.

Input: ([[], [9, 9, 9]], [-1, -1], -1, [False, False])

Expected Output: [[], [9]]

Explanation: A negative `first_n` means all rows are eligible. The empty row stays empty, and the second row is fully deduplicated.

Hints

  1. Process each row independently with a `seen` set while deduplication is active.
  2. Before touching a row, first decide whether it is eligible based on `first_n` and the exemption flag.
Last updated: May 30, 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
  • 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

  • Compute Minimum Task Completion Time - Netflix (medium)
  • 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)