FastPrepLongest Consecutive Identical Character Run
Problems/Longest Consecutive Identical Character Run

Longest Consecutive Identical Character Run

Netflix logoNetflix● EasyFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Netflix phone screen for a full-time role. The task is to find the length of the longest substring made of one repeated character. The report leaves out what happens for empty input and which characters are allowed. We filled those in.

Our version is about 96% the same as the reported question.

Given a string s, return the length of its longest nonempty consecutive run whose characters are all identical.

For this exercise, assume s contains only lowercase English letters and may be empty. Return 0 when s is empty.

Function

longestIdenticalRun(s: String) → int

Examples

Example 1

s = "aaabbc"return = 3

The prefix aaa is the longest identical-character run, so the answer is 3.

Example 2

s = "abbbbbaccc"return = 5

The run bbbbb has length 5, longer than every other run.

Example 3

s = ""return = 0

The empty string contains no nonempty run.

Constraints

  • s contains only lowercase English letters.
  • s may be empty.

More Netflix interview questions

  • Timed Cache with Sidecar CleanupPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Repeated Titles in Viewing HistoryPHONE SCREEN · Seen Sep 2026
  • Capacity-Limited Timed CachePHONE SCREEN · Seen Sep 2026
  • Custom Record and Free-Form Field ParserPHONE SCREEN · Seen Sep 2026
  • Dynamic Broadcast TimesPHONE SCREEN · Seen Aug 2026
  • Count String Pairs With Disjoint CharactersPHONE SCREEN · Seen Aug 2026
  • Deduplicate Homepage Content Across RowsPHONE SCREEN · Seen Aug 2026
  • Longest Substring Without Repeating CharactersPHONE SCREEN · Seen Aug 2026
  • Topological Sort for Ads TasksPHONE SCREEN · Seen Jun 2026
  • Score-Rotating Movie PlaylistONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Run-Length Encoding and DecodingAirbnb · PHONE SCREEN
  • Straight-Line Word SearchReddit · PHONE SCREEN
  • Search and Format ContactsAdyen · PHONE SCREEN
  • Subtract Two Large Number StringsStackAdapt · PHONE SCREEN
  • Transaction Fee Calculator — Parts 1–2: Basic Fee Calculation and Conditional Fee RulesStripe · PHONE SCREEN
  • Valid ParenthesesByteDance · PHONE SCREEN
  • Detect a Straight FlushTemu · PHONE SCREEN
  • Check if a String Is a PalindromeCisco · PHONE SCREEN
  • Halfway Course in a Single TrackCrunchyroll · PHONE SCREEN
  • Longest Common PrefixKotak Mahindra Bank · PHONE SCREEN · ONSITE INTERVIEW
See Netflix hiring insights
Saved
class Solution {
    public int longestIdenticalRun(String s) {
        // Your code here
    }
}
Checking account…