Skip to content

Commit 1e6b643

Browse files
update 752
1 parent 9714d06 commit 1e6b643

File tree

1 file changed

+28
-24
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+28
-24
lines changed

Diff for: src/main/java/com/fishercoder/solutions/_752.java

+28-24
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,35 @@ public class _752 {
66
public static class Solution1 {
77
public int openLock(String[] deadends, String target) {
88
// Map the next slot digit for each current slot digit.
9-
Map<Character, Character> nextSlot = new HashMap<Character, Character>() {{
10-
put('0', '1');
11-
put('1', '2');
12-
put('2', '3');
13-
put('3', '4');
14-
put('4', '5');
15-
put('5', '6');
16-
put('6', '7');
17-
put('7', '8');
18-
put('8', '9');
19-
put('9', '0');
20-
}};
9+
Map<Character, Character> nextSlot = new HashMap<Character, Character>() {
10+
{
11+
put('0', '1');
12+
put('1', '2');
13+
put('2', '3');
14+
put('3', '4');
15+
put('4', '5');
16+
put('5', '6');
17+
put('6', '7');
18+
put('7', '8');
19+
put('8', '9');
20+
put('9', '0');
21+
}
22+
};
2123
// Map the previous slot digit for each current slot digit.
22-
Map<Character, Character> prevSlot = new HashMap<Character, Character>() {{
23-
put('0', '9');
24-
put('1', '0');
25-
put('2', '1');
26-
put('3', '2');
27-
put('4', '3');
28-
put('5', '4');
29-
put('6', '5');
30-
put('7', '6');
31-
put('8', '7');
32-
put('9', '8');
33-
}};
24+
Map<Character, Character> prevSlot = new HashMap<Character, Character>() {
25+
{
26+
put('0', '9');
27+
put('1', '0');
28+
put('2', '1');
29+
put('3', '2');
30+
put('4', '3');
31+
put('5', '4');
32+
put('6', '5');
33+
put('7', '6');
34+
put('8', '7');
35+
put('9', '8');
36+
}
37+
};
3438

3539
// Set to store visited and dead-end combinations.
3640
Set<String> visited = new HashSet<>(Arrays.asList(deadends));

0 commit comments

Comments
 (0)