Skip to content

Instantly share code, notes, and snippets.

@qjatn0120
Created March 19, 2023 17:11
Show Gist options
  • Save qjatn0120/e3f009bd4f3a97fb0ef651fd4ef32296 to your computer and use it in GitHub Desktop.
Save qjatn0120/e3f009bd4f3a97fb0ef651fd4ef32296 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(nullptr), ios::sync_with_stdio(false);
int t;
cin >> t;
while(t--){
int n;
string s;
cin >> n >> s;
vector <int> chk1(26), chk2(26);
for(int i = 0; i < n; i++){
if(i & 1) chk1[s[i] - 'a']++;
else chk2[s[i] - 'a']++;
}
bool flag = true;
for(int i = 0; i < 26; i++) if(chk1[i] && chk2[i]) flag = false;
cout << (flag ? "Yes\n" : "No\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment