summaryrefslogtreecommitdiff
path: root/introductory_problems/repetitions.cpp
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2024-12-18 10:56:03 -0700
committerJack Sangdahl <[email protected]>2024-12-18 10:56:03 -0700
commitb4c9537fd8f13fcfc990f03b3731950fb6ae3759 (patch)
tree6384adb4f7dd8398bb61eb335ee253fac14024af /introductory_problems/repetitions.cpp
parent3d1f61c860eed7b034d5673197cdc04b5555f8e5 (diff)
downloadcses-b4c9537fd8f13fcfc990f03b3731950fb6ae3759.tar.gz
cses-b4c9537fd8f13fcfc990f03b3731950fb6ae3759.zip
1069. repetitions
Diffstat (limited to 'introductory_problems/repetitions.cpp')
-rw-r--r--introductory_problems/repetitions.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/introductory_problems/repetitions.cpp b/introductory_problems/repetitions.cpp
new file mode 100644
index 0000000..ab90db9
--- /dev/null
+++ b/introductory_problems/repetitions.cpp
@@ -0,0 +1,16 @@
+// 1069. Repetitions
+#include <bits/stdc++.h>
+using namespace std;
+
+const int max_size = 1e6 + 5;
+
+int main() {
+ char str[max_size];
+ scanf(" %s", str);
+ int num = strlen(str), curr = 1, cnt = 1;
+ for (int i = 1; i < num; i++) {
+ curr = str[i] == str[i - 1] ? curr + 1 : 1;
+ cnt = max(cnt, curr);
+ }
+ printf("%d\n", cnt);
+}