-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckifstring_canbe_madeequal.cpp
53 lines (53 loc) · 1.08 KB
/
checkifstring_canbe_madeequal.cpp
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
static const int __ = []() {
std::ios::sync_with_stdio(false);
std::cin.tie(NULL);
std::cout.tie(NULL);
return 0;
}();
class Solution {
public:
bool checkStrings(string s1, string s2) {
int i, j;
int n1 = s1.size();
int n2 = s2.size();
unordered_map<char, int> mpo1, mpo2, mpe1, mpe2;
for (i = 0; i < n1; i++) {
if (i % 2 == 0) {
mpe1[s1[i]]++;
} else {
mpo1[s1[i]]++;
}
}
for (i = 0; i < n2; i++) {
if (i % 2 == 0) {
mpe2[s2[i]]++;
} else {
mpo2[s2[i]]++;
}
}
for (auto k : mpo1) {
cout << k.first << k.second << ";"
<< "\t";
}
cout << endl;
for (auto k : mpo2) {
cout << k.first << k.second << ";"
<< "\t";
}
cout << endl;
for (auto k : mpe1) {
cout << k.first << k.second << ";"
<< "\t";
}
cout << endl;
for (auto k : mpe2) {
cout << k.first << k.second << ";"
<< "\t";
}
cout << endl;
if (mpo1 == mpo2 && mpe1 == mpe2) {
return true;
}
return false;
}
};