We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7c12ebb commit 1acecafCopy full SHA for 1acecaf
lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13/Lesson13.java
@@ -6,14 +6,14 @@ public class Lesson13 {
6
public int findPermutationDifference(String s, String t) {
7
var indexMap = new HashMap<Character, Integer>();
8
for (int i = 0; i < t.length(); i++) {
9
- indexMap.put(t.charAt(i), i);
+ indexMap.put(t.charAt(i), i);
10
}
11
12
int result = 0;
13
for (int i = 0; i < s.length(); i++) {
14
- // Default to -1 if char not found
15
- result += Math.abs(i - indexMap.getOrDefault(s.charAt(i), -1));
+ // Default to -1 if char not found
+ result += Math.abs(i - indexMap.getOrDefault(s.charAt(i), -1));
16
17
return result;
18
- }
+ }
19
0 commit comments