#1446
Consecutive Characters
pupil · 370 · lc easy +23 · verified · 60.3% accepted · 1,844 likes · top 59%
Description
Define the power of a string as the length of its longest non-empty run of identical characters. Given a string s, compute and return its power.
Example 1:
Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.
Example 2:
Input: s = "abbcccddddeeeeedcba"
Output: 5
Explanation: The substring "eeeee" is of length 5 with the character 'e' only.
Code
1
2
3