【leetcode】1446. Consecutive Characters
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.
Example 1:
Input: s = "leetcode"
Output: 2
Explanation: The substring "ee" is of length 2 with the character 'e' only.
统计字符串中最长的连续字符串长度,利用双指针进行维护。
class Solution {
public:
int maxPower(string s) {
// 双指针
int res=0;
int low=0,fast=0;
while(low