Trains the technique from
LeetCode 1446Consecutive CharactersThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A tape of lowercase letters reads tape.
Return the length of the longest stretch of neighbouring positions all holding the same letter.
Example 1
The three b's in the middle form the longest stretch; the a's and the c's manage only two apiece.
Example 2
The whole tape is one letter repeated, so the stretch runs the full length.
Example 3
No two neighbouring letters match, so every stretch holds a single letter.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def max_power(tape: str) -> int:public int maxPower(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.