Skip to content

Commit e9cf54d

Browse files
committed
Added 1520A - Do Not Be Distracted!.cpp
1 parent a4cbdad commit e9cf54d

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

1520A - Do Not Be Distracted!.cpp

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
6+
// Code Written By: Vikash Patel
7+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8+
9+
10+
bool checkV(vector<char> t, char ch)
11+
{
12+
for(auto i : t)
13+
{
14+
if(i==ch)
15+
return 1;
16+
}
17+
return 0;
18+
}
19+
20+
int main()
21+
{
22+
int t;
23+
cin>>t;
24+
while(t--)
25+
{
26+
int n;
27+
string s;
28+
cin>>n>>s;
29+
vector<char> temp;
30+
int ans = 1;
31+
for(int i=0;i<n;i++)
32+
{
33+
if(checkV(temp, s[i]))
34+
{
35+
ans = 0;
36+
break;
37+
}
38+
if(s[i]!=s[i+1])
39+
temp.push_back(s[i]);
40+
}
41+
if(ans)
42+
cout<<"YES"<<endl;
43+
else
44+
cout<<"NO"<<endl;
45+
}
46+
return 0;
47+
}

0 commit comments

Comments
 (0)