-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp9.cpp
More file actions
68 lines (56 loc) · 1.12 KB
/
Copy pathp9.cpp
File metadata and controls
68 lines (56 loc) · 1.12 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
Given two strings of equal length, you have to tell whether they both strings are identical.
3
sumit
mitsu
ambuj
jumba
abhi
hibb
o/p
YES
YES
NO
*/
#include<iostream>
#include<unordered_map>
#include<string>
using namespace std;
int main()
{
int T,size,i;
string str;
unordered_map<char,int> mapping1,mapping2;
unordered_map<char,int>:: iterator it;
cin>>T;
while(T--)
{
cin>>str;
size = str.size();
for(i=0;i<size;i++)
mapping1[str[i]] = 0;
for(i=0;i<size;i++)
mapping1[str[i]] = ++mapping1[str[i]];
cin>>str;
for(i=0;i<size;i++)
mapping2[str[i]] = 0;
for(i=0;i<size;i++)
mapping2[str[i]] = ++mapping2[str[i]] ;
for(it = mapping1.begin();it!=mapping1.end();it++)
{
if(mapping2.find(it->first) == mapping2.end())
{
cout<<"NO"<<endl;
break;
}
else if((mapping2.find(it->first))->second != it->second)
{
cout<<"NO"<<endl;
break;
}
}
if(it==mapping1.end())
cout<<"YES"<<endl;
mapping1.clear(); mapping2.clear();
}
}