Skip to content

Commit 2cdb680

Browse files
committed
fix:lesson13.java file made more concise
1 parent ef98f71 commit 2cdb680

File tree

1 file changed

+4
-6
lines changed
  • lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13

1 file changed

+4
-6
lines changed

lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13/Lesson13.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ public int findPermutationDifference(String s, String t) {
1616
smap.put(s.charAt(i), i);
1717
tmap.put(t.charAt(i), i);
1818
}
19-
for (Character key : smap.keySet()) {
20-
if (tmap.containsKey(key)) {
21-
Integer val1 = smap.get(key);
22-
Integer val2 = tmap.get(key);
23-
sum += Math.abs(val1 - val2);
24-
}
19+
for (char key : smap.keySet()) {
20+
int val1 = smap.get(key);
21+
int val2 = tmap.get(key);
22+
sum += Math.abs(val1 - val2);
2523
}
2624
return sum;
2725
}

0 commit comments

Comments
 (0)