We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a4cbdad commit e9cf54dCopy full SHA for e9cf54d
1520A - Do Not Be Distracted!.cpp
@@ -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
47
0 commit comments