Skip to content

Commit 88cf4a6

Browse files
Added solutions
1 parent 9a2e3db commit 88cf4a6

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
int makeAnagram(string a, string b) {
5+
6+
char hashmap[26] = {0};
7+
8+
for(auto& c: a)hashmap[c-'a']++;
9+
for(auto& c: b)hashmap[c-'a']--; //all repeated characters get 0 as their count in the freq
10+
11+
int count = 0;
12+
for(auto& x : hashmap)count += abs(x);
13+
14+
return count;
15+
}
16+
17+
int main()
18+
{
19+
ofstream fout(getenv("OUTPUT_PATH"));
20+
string a;
21+
getline(cin, a);
22+
string b;
23+
getline(cin, b);
24+
int res = makeAnagram(a, b);
25+
fout << res << "\n";
26+
fout.close();
27+
return 0;
28+
}

0 commit comments

Comments
 (0)