Practice/Meta/Leetcode 1446. Consecutive Characters
CodingOptional
Given a string s containing only lowercase English letters, find the length of the longest consecutive sequence of identical characters. In other words, determine the maximum number of times the same character appears consecutively in the string.
s.length ≤ 500s consists of only lowercase English lettersExample 1:
Input: s = "aaabbcc" Output: 3 Explanation: The character 'a' appears 3 times consecutively at the beginning, which is the longest streak.
Example 2:
Input: s = "abcdef" Output: 1 Explanation: All characters are different, so the longest streak is 1.
Example 3:
Input: s = "zzzzz" Output: 5 Explanation: The entire string is one continuous streak of 'z'.
Example 4:
Input: s = "aabbbccccdddeee" Output: 4 Explanation: 'c' appears 4 times consecutively, which is the longest streak in the string.