File tree 1 file changed +28
-24
lines changed
src/main/java/com/fishercoder/solutions
1 file changed +28
-24
lines changed Original file line number Diff line number Diff line change @@ -6,31 +6,35 @@ public class _752 {
6
6
public static class Solution1 {
7
7
public int openLock (String [] deadends , String target ) {
8
8
// 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
+ };
21
23
// 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
+ };
34
38
35
39
// Set to store visited and dead-end combinations.
36
40
Set <String > visited = new HashSet <>(Arrays .asList (deadends ));
You can’t perform that action at this time.
0 commit comments