@@ -9,20 +9,20 @@ public class Lesson13 {
9
9
* https://leetcode.com/problems/permutation-difference-between-two-strings
10
10
*/
11
11
public int findPermutationDifference (String s , String t ) {
12
- HashMap <Character ,Integer > smap = new HashMap <>();
13
- HashMap <Character ,Integer > tmap = new HashMap <>();
14
- int sum = 0 ;
15
- for (int i =0 ; i <s .length (); i ++){
16
- smap .put (s .charAt (i ),i );
17
- tmap .put (t .charAt (i ),i );
18
- }
19
- for (Character key : smap .keySet ()){
20
- if (tmap .containsKey (key )) {
21
- Integer val1 = smap .get (key );
22
- Integer val2 = tmap .get (key );
23
- sum += Math .abs (val1 - val2 );
24
- }
25
- }
26
- return sum ;
12
+ HashMap <Character , Integer > smap = new HashMap <>();
13
+ HashMap <Character , Integer > tmap = new HashMap <>();
14
+ int sum = 0 ;
15
+ for (int i = 0 ; i < s .length (); i ++) {
16
+ smap .put (s .charAt (i ), i );
17
+ tmap .put (t .charAt (i ), i );
18
+ }
19
+ for (Character key : smap .keySet ()) {
20
+ if (tmap .containsKey (key )) {
21
+ Integer val1 = smap .get (key );
22
+ Integer val2 = tmap .get (key );
23
+ sum += Math .abs (val1 - val2 );
24
+ }
25
+ }
26
+ return sum ;
27
27
}
28
28
}
0 commit comments