Skip to content

Commit 7e75002

Browse files
authored
Create 1347 Minimum number of steps to make two strings anagram.cpp
1 parent 60a4e99 commit 7e75002

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public:
3+
int minSteps(string s, string t) {
4+
vector<int> freq(26,0);
5+
6+
for (char ch:s) ++freq[ch-'a'];
7+
for (char ch:t) --freq[ch-'a'];
8+
9+
return accumulate(freq.begin(),freq.end(),0,[](int sum, int count) {
10+
return sum+abs(count);
11+
}) / 2;
12+
}
13+
};

0 commit comments

Comments
 (0)