Skip to content

Commit 1c44f44

Browse files
committed
feat: fixed syntax error for lesson_13.ts
1 parent 7778f4c commit 1c44f44

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

lesson_13/maps_ts/src/lesson13.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
* https://leetcode.com/problems/permutation-difference-between-two-strings
44
*/
55
export function findPermutationDifference(s: string, t: string): number {
6-
let charLocation = new Map<string, number>();
7-
let charSum = 0;
8-
for (let i = 0; i < s.length; i++) {
9-
charLocation.set(s[i], i);
10-
}
11-
for (let i = 0; i < t.length; i++) {
12-
let charResult = charLocation.get(t.charAt(i));
6+
const charLocation = new Map<string, number>();
7+
let charSum = 0;
8+
for (let i = 0; i < s.length; i++) {
9+
charLocation.set(s[i], i);
10+
}
11+
for (let i = 0; i < t.length; i++) {
12+
const charResult = charLocation.get(t.charAt(i));
13+
if (charResult !== undefined) {
1314
charSum += Math.abs(charResult - i);
1415
}
15-
return charSum;
16-
16+
}
17+
return charSum;
1718
}

0 commit comments

Comments
 (0)