CSES Solutions
#1069Introductory Problems

Repetitions

View on CSES

Solution

1069-Repetitions.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4signed main(){
5  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
6  string s; cin>>s;
7  int ans=0;
8  for(int i=0,run=0;i<(int)s.size();++i){
9    if(i&&s[i]==s[i-1]) ++run;
10    else run=1;
11    ans=max(ans,run);
12  }
13  cout<<ans<<'\n';
14  return 0;
15}

Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.