We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 39c8f59 commit 1b08d0fCopy full SHA for 1b08d0f
lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13/Lesson13.java
@@ -7,6 +7,17 @@ public class Lesson13 {
7
* https://leetcode.com/problems/permutation-difference-between-two-strings
8
*/
9
public int findPermutationDifference(String s, String t) {
10
- return 0;
+ 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;
22
}
23
0 commit comments