blob: 6d45b6b8197d87bec025f92a619158876bcfaf66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include <bits/stdc++.h>
using namespace std;
int solve(int window) {
string s;
cin >> s;
for (int i = 0; i < s.size() - window; i++) {
set<char> st;
for (int j = i; j < i + window; j++) {
st.insert(s[j]);
}
if (st.size() == window) {
return i + window;
}
}
return -1;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout << "Part1: " << solve(4);
// cout << "Part2: " << solve(14);
}
|