#include<iostream> using namespace std; int maxLen(string newstr){ int i=0; int max_len=0; int n=newstr.size(); while(i<n){ int temp_len=0; char br=' '; while(i<n){ if(newstr[i]=='w' || newstr[i]==br){ temp_len++; i++; continue; } if(br==' '){ br=newstr[i]; temp_len++; i++; continue; } if(br!=newstr[i]) break; } if(max_len<temp_len){ max_len=temp_len; } } return max_len; } int main(){ string str="rrrrrbrrbbrbbbbrrrrbbrbrrrbbb"; int n; n=maxLen(str); cout<<n<<endl; return 0; }