Skip to content

Commit ab759a5

Browse files
add 2186
1 parent a0b9a32 commit ab759a5

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ _If you like this project, please leave me a star._ ★
88

99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|------|----------------|---------------|--------|-------------|-------------
11+
| 2186 |[Minimum Number of Steps to Make Two Strings Anagram II](https://leetcode.com/problems/minimum-number-of-steps-to-make-two-strings-anagram-ii/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2186.java) ||Medium||
1112
| 2185 |[Counting Words With a Given Prefix](https://leetcode.com/problems/counting-words-with-a-given-prefix/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2185.java) ||Easy||
1213
| 2182 |[Construct String With Repeat Limit](https://leetcode.com/problems/construct-string-with-repeat-limit/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2182.java) ||Medium||
1314
| 2181 |[Merge Nodes in Between Zeros](https://leetcode.com/problems/merge-nodes-in-between-zeros/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2181.java) ||Medium||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2186 {
4+
public static class Solution1 {
5+
public int minSteps(String s, String t) {
6+
int[] counts = new int[26];
7+
for (int i = 0; i < s.length(); i++) {
8+
counts[s.charAt(i) - 'a']++;
9+
}
10+
for (int i = 0; i < t.length(); i++) {
11+
counts[t.charAt(i) - 'a']--;
12+
}
13+
int ans = 0;
14+
for (int i = 0; i < counts.length; i++) {
15+
ans += Math.abs(counts[i]);
16+
}
17+
return ans;
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)