File tree Expand file tree Collapse file tree 1 file changed +9
-10
lines changed
lesson_13/maps_java/maps_app/src/main/java/com/codedifferently/lesson13 Expand file tree Collapse file tree 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -8,19 +8,18 @@ public class Lesson13 {
88 * Provide the solution to LeetCode 3146 here:
99 * https://leetcode.com/problems/permutation-difference-between-two-strings
1010 */
11-
1211 public int findPermutationDifference (String s , String t ) {
13-
14- //var charLocation = new HashMap<Character, Integer>();
1512
16- HashMap <Character ,Integer > map = new HashMap ();
17- int sum =0 ;
18- for (int i =0 ; i < s .length (); i ++) {
19- map .putIfAbsent (s .charAt (i ),i );
13+ // var charLocation = new HashMap<Character, Integer>();
14+
15+ HashMap <Character , Integer > map = new HashMap ();
16+ int sum = 0 ;
17+ for (int i = 0 ; i < s .length (); i ++) {
18+ map .putIfAbsent (s .charAt (i ), i );
2019 }
21- for (char key : map .keySet ()) {
22- int indexInt = t .indexOf (Character .toString (key ));
23- sum += Math .abs (s .indexOf (key )- indexInt );
20+ for (char key : map .keySet ()) {
21+ int indexInt = t .indexOf (Character .toString (key ));
22+ sum += Math .abs (s .indexOf (key ) - indexInt );
2423 }
2524 return sum ;
2625 }
You can’t perform that action at this time.
0 commit comments