-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12.cpp
More file actions
41 lines (38 loc) · 717 Bytes
/
12.cpp
File metadata and controls
41 lines (38 loc) · 717 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
#include<bits/stdc++.h>
using namespace std;
int main()
{
string s,out,last;
int size,ctr=0;
cin>>s;
size=s.size();
vector<int> alph(26,0);
for(int i=0;i<size;i++)
{
alph[s[i]-'A']++;
}
for(int i=0;i<26;i++)
{
if(alph[i]%2==0)
{
for(int j=0;j<alph[i]/2;j++)
out+=('A'+i);
}
else
{
for(int j=0;j<alph[i];j++)
last+=('A'+i);
ctr++;
}
}
if((size%2==0&&ctr==0)||(size%2!=0&&ctr==1))
{
cout<<out<<last;
reverse(out.begin(),out.end());
cout<<out;
}
else
{
cout<<"NO SOLUTION";
}
}