Skip to content

Commit 8d3e859

Browse files
committed
Runtime: 28 ms (Top 46.01%) | Memory: 46.5 MB (Top 66.67%)
1 parent 25f5cba commit 8d3e859

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

scripts/algorithms/F/Freedom Trail/Freedom Trail.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 28 ms (Top 46.01%) | Memory: 46.5 MB (Top 66.67%)
12
class Solution {
23
public int findRotateSteps(String ring, String key) {
34
Map<Character, TreeSet<Integer>> locMap = new HashMap<>();
@@ -19,7 +20,7 @@ private int dfs(int cur, int where, Map<Character, TreeSet<Integer>> locMap, Str
1920
return memo[cur][where]=dfs(cur+1, where, locMap, key, memo)+1;
2021
}
2122
Integer hi = idx.higher(where); // otherwise, we can take the higher key
22-
Integer lo = idx.lower(where); // or, the lower key
23+
Integer lo = idx.lower(where); // or, the lower key
2324
if (hi == null){ // if no higher key, it becomes the lowest key.
2425
hi = idx.first();
2526
}
@@ -30,4 +31,4 @@ private int dfs(int cur, int where, Map<Character, TreeSet<Integer>> locMap, Str
3031
int lcost = dfs(cur+1, lo, locMap, key, memo) + (lo<where? where-lo:where+memo[0].length-lo);
3132
return memo[cur][where]=Math.min(hcost, lcost)+1;
3233
}
33-
}
34+
}

0 commit comments

Comments
 (0)