-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1766B.cpp
More file actions
55 lines (48 loc) · 1.21 KB
/
Copy path1766B.cpp
File metadata and controls
55 lines (48 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Created on 12-Sep-25
//done
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL)
#define getUnique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
#define nl '\n'
int main() {
faster;
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string s;
cin >> s;
int sz = s.size();
map<string, int> freq;
string temp1, temp2;
bool f = false;
for (int i = 0; i < sz - 1; i++) {
temp1 = s.substr(i, 2);
// for excluding 0 index
if (i) {
temp2 = s.substr(i - 1, 2);
}
if (temp1 == temp2 && f == false) { //edge case hhh,hhhh
f = true;
} else {
freq[temp1]++;
f = false;
}
}
bool foundOne = false;
for (auto u: freq) {
if (u.second > 1) {
foundOne = true;
break;
}
}
if (foundOne) cout << "Yes" << nl;
else cout << "No" << nl;
}
return 0;
}