-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvalid.cpp
More file actions
44 lines (39 loc) · 872 Bytes
/
Copy pathsvalid.cpp
File metadata and controls
44 lines (39 loc) · 872 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<string>
#include<vector>
#include<map>
using namespace std;
int main()
{
int a;
map<char,int> m;
map<int,int> count;
//map<char, int>::iterator itr;
string ss;
cout<<"enter the string";
cin>>ss;
for(char i:ss)
m[i]++;
/*for (itr = m.begin(); itr != m.end(); ++itr) {
cout << '\t' << itr->first << '\t' << itr->second
<< '\n';
}*/
for (const auto& x : m) {
std::cout << x.first << ": " << x.second << "\n";
count[x.second]++;
}
for (const auto& x : count)
std::cout << x.first << ": " << x.second << "\n";
int len = count.size(),flag=0,temp;
if(len>2)
cout<<"NO";
for (const auto& x : count)
if(x.second==1&&x.second){
flag=1;
break;
}
if(flag==1)
cout<<"YES";
else
cout<<"NO";
}