Skip to content

Commit c2e5662

Browse files
committed
chore: rename sMap and tMap
1 parent 2cdb680 commit c2e5662

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ public class Lesson13 {
99
* https://leetcode.com/problems/permutation-difference-between-two-strings
1010
*/
1111
public int findPermutationDifference(String s, String t) {
12-
HashMap<Character, Integer> smap = new HashMap<>();
13-
HashMap<Character, Integer> tmap = new HashMap<>();
12+
HashMap<Character, Integer> sMap = new HashMap<>();
13+
HashMap<Character, Integer> tMap = new HashMap<>();
1414
int sum = 0;
1515
for (int i = 0; i < s.length(); i++) {
16-
smap.put(s.charAt(i), i);
17-
tmap.put(t.charAt(i), i);
16+
sMap.put(s.charAt(i), i);
17+
tMap.put(t.charAt(i), i);
1818
}
19-
for (char key : smap.keySet()) {
20-
int val1 = smap.get(key);
21-
int val2 = tmap.get(key);
19+
for (char key : sMap.keySet()) {
20+
int val1 = sMap.get(key);
21+
int val2 = tMap.get(key);
2222
sum += Math.abs(val1 - val2);
2323
}
2424
return sum;

lesson_13/maps_ts/src/lesson13.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
* https://leetcode.com/problems/permutation-difference-between-two-strings
44
*/
55
export function findPermutationDifference(s: string, t: string): number {
6-
const smap = new Map<string, number>();
6+
const sMap = new Map<string, number>();
77
let sum = 0;
88
for (let i = 0; i < s.length; i++) {
9-
smap.set(s.charAt(i), i);
9+
sMap.set(s.charAt(i), i);
1010
}
11-
for (const key of smap.keys()) {
12-
const val1 = smap.get(key);
11+
for (const key of sMap.keys()) {
12+
const val1 = sMap.get(key);
1313
if (val1 !== undefined) {
1414
sum += Math.abs(val1 - t.indexOf(key));
1515
}

0 commit comments

Comments
 (0)