Skip to content

Commit c5d795c

Browse files
author
AmiyahJo
committed
chore: remove comments
1 parent 86d6a12 commit c5d795c

File tree

2 files changed

+4
-18
lines changed

2 files changed

+4
-18
lines changed

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,18 @@
44

55
public class Lesson13 {
66

7-
/**
8-
* Provide the solution to LeetCode 3146 here:
9-
* https://leetcode.com/problems/permutation-difference-between-two-strings
10-
*/
117
public int findPermutationDifference(String s, String t) {
128
var charIndexMap = new HashMap<Character, Integer>();
139

1410
int totalDifference = 0;
1511

1612
for (int sIndex = 0; sIndex < s.length(); sIndex++) {
1713
charIndexMap.put(s.charAt(sIndex), sIndex);
18-
//keeps track of the position for each character in 's'
1914
}
2015

2116
for (int tIndex = 0; tIndex < t.length(); tIndex++) {
2217
int indexInS = charIndexMap.get(t.charAt(tIndex));
23-
//Same as sIndex , but this loop keeps track of each character in t
2418
totalDifference += Math.abs(indexInS - tIndex);
25-
//adds all the differences
2619
}
2720

2821
return totalDifference;

lesson_13/maps_ts/src/lesson13.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
/**
2-
* Provide the solution to LeetCode 3146 here:
3-
* https://leetcode.com/problems/permutation-difference-between-two-strings
4-
*/
51
export function findPermutationDifference(s: string, t: string): number {
6-
//Create a way to find the index of each character in string s.
7-
// This could be a list or a dictionary where each character points to its index in s.
82
let charPositionMap = new Map<string, number>();
9-
//Start with a variable to keep track of the total permutation difference. Set it to 0.
3+
104
let totalDifference = 0;
11-
//For each character in t, find its index in s using the mapping you created.
5+
126
for (let sIndex = 0; sIndex < s.length; sIndex++) {
137
charPositionMap.set(s.charAt(sIndex), sIndex)
148
}
159

1610
for (let tIndex = 0; tIndex < t.length; tIndex++) {
17-
//Calculate the absolute difference between the index in s and the current index in t.
1811
let indexInS = charPositionMap.get(t.charAt(tIndex));
19-
//Add the absolute difference you calculated to the total difference.
12+
2013
if (indexInS != undefined) {
2114
totalDifference += Math.abs(indexInS - tIndex);
2215
}
2316
}
24-
//After going through all characters in t, return the total difference.
17+
2518
return totalDifference;
2619
}

0 commit comments

Comments
 (0)