Longest Consecutive Identical Character Run
Updated
Problem statement
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) → intExamples
Example 1
s = "aaabbc"return = 3The prefix aaa is the longest identical-character run, so the answer is 3.
Example 2
s = "abbbbbaccc"return = 5The run bbbbb has length 5, longer than every other run.
Example 3
s = ""return = 0The empty string contains no nonempty run.
Constraints
scontains only lowercase English letters.smay 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