File tree Expand file tree Collapse file tree 1 file changed +3
-3
lines changed
lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13 Expand file tree Collapse file tree 1 file changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ public class Lesson13 {
15
15
* 2 the math: |0 - 1| + |1 - 0| + \2 - 2| = |-1| + |1| + |0| = 1 + 1 + 0 = 2 we return 2
16
16
*/
17
17
public int findPermutationDifference (String s , String t ) {
18
- var compareStrings = new HashMap <Character , Integer >();
18
+ var stringMap = new HashMap <Character , Integer >();
19
19
int total = 0 ;
20
20
21
21
for (int i = 0 ; i < s .length (); i ++) {
22
- compareStrings .put (s .charAt (i ), s .indexOf (s .charAt (i )));
22
+ stringMap .put (s .charAt (i ), s .indexOf (s .charAt (i )));
23
23
}
24
24
25
25
for (int i = 0 ; i < t .length (); i ++) {
26
- int absDiff = Math .abs (compareStrings .get (s .charAt (i )) - t .indexOf (s .charAt (i )));
26
+ int absDiff = Math .abs (stringMap .get (s .charAt (i )) - t .indexOf (s .charAt (i )));
27
27
total += absDiff ;
28
28
}
29
29
return total ;
You can’t perform that action at this time.
0 commit comments