Skip to content

Commit 4bb2ad7

Browse files
committed
feat:Adds PermutationDifference to Dasias Lesson_13
1 parent 32f5984 commit 4bb2ad7

File tree

1 file changed

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

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ 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+
11+
int sumDifference = 0;
12+
for (int i = 0; i < s.length(); i++) {
13+
char currentChar = s.charAt(i);
14+
int indexInT = t.indexOf(currentChar);
15+
int difference = Math.abs(i - indexInT);
16+
sumDifference += difference;
17+
}
18+
System.out.println("Here is the Permutation Difference is: + letters.get");
19+
return sumDifference;
1120
}
1221
}

0 commit comments

Comments
 (0)