Skip to content

Practice Consecutive Characters

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#1446
LeetCode Problem

Consecutive Characters

Problem Statement

The power of the string is the maximum length of a non-empty substring that contains only one unique character. Given a string s, return the power of s.

Source: Consecutive Characters on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leetcode"
Output
2

# Example 2

Input
s = "abbcccddddeeeeedcba"
Output
5

Constraints

1 <= s.length <= 500
s consists of only lowercase English letters.

Related LeetCode Problems

Practice more problems similar to Consecutive Characters.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.