-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiffstr.cpp
More file actions
43 lines (38 loc) · 830 Bytes
/
Copy pathdiffstr.cpp
File metadata and controls
43 lines (38 loc) · 830 Bytes
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
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
string str;
cin >> str;
int n = str.size();
int cnt=0;
map<string, int> frequency;
for (int i = 0; i < n; i++) {
string substr = str.substr(i, 1);
frequency[substr]++;
}
for (auto &pair : frequency) {
if(pair.second>0)
{
cnt++;
}
}
if(cnt==1)
{
cout<<"NO"<<endl;
}
else
{
cout<<"YES"<<endl;
cout<<str[n-1];
for(int i=0;i<n-1;i++)
{
cout<<str[i];
}
cout<<endl;
}
}
return 0;
}