-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathDuplicate Character.cpp
More file actions
44 lines (44 loc) · 850 Bytes
/
Copy pathDuplicate Character.cpp
File metadata and controls
44 lines (44 loc) · 850 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
44
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
string unique(string s)
{ string str;
int len = s.length();
for(int i = 0; i < len; i++)
{char c = s[i];
auto found = str.find(c);
if (found == std::string::npos) str += c;
}
return str;
}
int main()
{
int t;
cin>>t;
while(t--)
{ int k=0;
string s;
cin>>s;
int a[1256]={0};
for(int i=0;s[i]!='\0';i++)
{
int p=s[i]-'a';
a[p]++;
}
sort(s.begin(),s.end());
int n=s.size();
s=unique(s);
for(int i=0;s[i]!='\0';i++)
{
int p=s[i]-'a';
if(a[p]==1)
{ cout<<"";}
else{ k=1;
cout<<s[i]<<"="<<a[p]<<" ";
}
}
if(k==0)
cout<<"-1";
cout<<"\n";
}
}