Consecutive Characters
EasyStringssimulation
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a string s, find the length of the longest block of adjacent characters that are all the same character.
Return that length as an integer. Since s is non-empty, the answer is always at least 1.
Examples
Input: s = "abbcccddcc"
Output: 3
The run "ccc" has length 3, the longest in the string.
Input: s = "z"
Output: 1
A single character forms a run of length 1.
Constraints
- 1 <= s.length <= 500
- `s` consists only of lowercase English letters
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.