Skip to content

Commit 474f699

Browse files
committed
feat: adds lesson_13 Java & TypeScript
1 parent c9f5fa1 commit 474f699

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ public class Lesson13 {
77
* https://leetcode.com/problems/permutation-difference-between-two-strings
88
*/
99
public int findPermutationDifference(String s, String t) {
10-
return 0;
10+
int total = 0;
11+
12+
for (int i = 0; i < s.length(); i++) {
13+
char ch = s.charAt(i);
14+
int idx2 = t.indexOf(ch);
15+
16+
total += Math.abs(i - idx2);
17+
}
18+
return total;
1119
}
1220
}

lesson_13/maps_ts/src/lesson13.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,13 @@
33
* https://leetcode.com/problems/permutation-difference-between-two-strings
44
*/
55
export function findPermutationDifference(s: string, t: string): number {
6-
return 0;
6+
let total = 0;
7+
8+
for (let i = 0; i < s.length; i++) {
9+
const ch = s.charAt(i);
10+
const idx2 = t.indexOf(ch);
11+
12+
total += Math.abs(i - idx2);
13+
}
14+
return total;
715
}

0 commit comments

Comments
 (0)