Skip to content

Commit 1b08d0f

Browse files
committed
feat: Lesson 13 Java by Dwight Blue
1 parent 39c8f59 commit 1b08d0f

File tree

1 file changed

+12
-1
lines changed
  • lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13

1 file changed

+12
-1
lines changed

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ 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+
var sum = 0;
11+
char[] charArray1 = s.toCharArray();
12+
char[] charArray2 = t.toCharArray();
13+
14+
for (int i = 0; i < s.length(); i++) {
15+
for (int j = 0; j < t.length(); j++) {
16+
if (charArray1[i] == charArray2[j]) {
17+
sum = sum + Math.abs(i - j);
18+
}
19+
}
20+
}
21+
return sum;
1122
}
1223
}

0 commit comments

Comments
 (0)