双指针算法解
时间复杂度:O(T$\ast$n)
#include<iostream>
#include<string>
using namespace std;
int main()
{
int n,max_size=0;
char c;
string word;
word += ' ';
cin>>n;
while(n--)
{
int now_size=0;
cin>>word;
for(int i=0,j=0;i<word.size()+1;i++)
{
if(word[i]==word[j]) now_size++;
else {
if(now_size>max_size) max_size = now_size,c=word[j];
j=i,now_size=1;
}
}
cout<<c<<' '<<max_size<<endl;
max_size=0;
}
}