From ed30499f7213c756c75527673dd9dbcc1bf059b5 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Tue, 1 Nov 2022 13:18:09 +0200 Subject: Added first 3 problem of CSES problem set --- cses/Repetitions/main.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 cses/Repetitions/main.cpp (limited to 'cses/Repetitions/main.cpp') diff --git a/cses/Repetitions/main.cpp b/cses/Repetitions/main.cpp new file mode 100644 index 0000000..cc45f63 --- /dev/null +++ b/cses/Repetitions/main.cpp @@ -0,0 +1,21 @@ +#include + +using namespace std; + +int main () { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + string s; + cin >> s; + int mx = 1; + int cnt = 1; + for (int i = 0; i < s.length() - 1; ++i) { + if(s[i] == s[i + 1]) { + cnt++; + mx = max(mx, cnt); + } else { + cnt = 1; + } + } + cout << mx << endl; +} -- cgit v1.2.3