Given a string S as the input, print the
distinct alphabets in S that occur more than once. The alphabets must be
printed based on the order of their occurrence in S.
Input
Format:
The first line contains S.
Output
Format:
The first line contains the distinct
alphabets in S that occur more than once.
Boundary
Conditions:
2 <= LENGTH of S <= 200
Example
Input/Output 1:
Input:
Apple
Output:
p
Example
Input/Output 2:
Input:
environment
Output:
en
Solution:
#include <bits/stdc++.h>
using namespace std;
int main()
{
string s,x;
cin>>s;
map<char,int> m;
for(int i=0;i<s.length();i++)
{
m[s[i]]++;
if(m[s[i]]==1)
x+=s[i];
}
for(int i=0;i<x.length();i++)
if(m[x[i]]>1)
cout<<x[i];
}