File tree Expand file tree Collapse file tree 1 file changed +15
-15
lines changed
lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13 Expand file tree Collapse file tree 1 file changed +15
-15
lines changed Original file line number Diff line number Diff line change 1
1
package com .codedifferently .lesson13 ;
2
+
2
3
import java .util .HashMap ;
3
4
4
5
public class Lesson13 {
@@ -9,22 +10,21 @@ public class Lesson13 {
9
10
*/
10
11
public int findPermutationDifference (String s , String t ) {
11
12
12
- HashMap <Character , Integer > indexFinder = new HashMap <>();
13
-
14
-
15
- for (int i = 0 ; i < s .length (); i ++) {
16
- char character = s .charAt (i );
17
- indexFinder .put (character , i );
18
- }
13
+ HashMap <Character , Integer > indexFinder = new HashMap <>();
19
14
20
- int sum = 0 ;
15
+ for (int i = 0 ; i < s .length (); i ++) {
16
+ char character = s .charAt (i );
17
+ indexFinder .put (character , i );
18
+ }
21
19
22
- for (int i = 0 ; i < t .length (); i ++) {
23
- char character = t .charAt (i );
24
- int value = indexFinder .get (character );
25
- sum += Math .abs (value - i );
26
- }
20
+ int sum = 0 ;
27
21
28
- return sum ;
22
+ for (int i = 0 ; i < t .length (); i ++) {
23
+ char character = t .charAt (i );
24
+ int value = indexFinder .get (character );
25
+ sum += Math .abs (value - i );
29
26
}
30
- }
27
+
28
+ return sum ;
29
+ }
30
+ }
You can’t perform that action at this time.
0 commit comments