Problem · String
Longest Consecutive Identical Character Run
Learn this problemProblem 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 problems
- 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
- Movie Billboard RotationONSITE INTERVIEW · Seen Jul 2026
- Topological Sort for Ads TasksPHONE SCREEN · Seen Jun 2026
- Command Undo Data StructureONSITE INTERVIEW · Seen Apr 2026
- Timed Cache with Sidecar CleanupONSITE INTERVIEW · Seen Apr 2026