File tree Expand file tree Collapse file tree 1 file changed +0
-7
lines changed
src/main/java/g0701_0800/s0752_open_the_lock Expand file tree Collapse file tree 1 file changed +0
-7
lines changed Original file line number Diff line number Diff line change @@ -13,28 +13,21 @@ public int openLock(String[] deadEnds, String target) {
1313 for (String end : deadEnds ) {
1414 visited .add (Integer .parseInt (end ));
1515 }
16-
1716 if (visited .contains (0 )) {
1817 return -1 ;
1918 }
20-
2119 Queue <int []> queue = new LinkedList <>();
22-
2320 queue .add (new int [] {0 , 0 });
2421 visited .add (0 );
25-
2622 int numTarget = Integer .parseInt (target );
27-
2823 while (!queue .isEmpty ()) {
2924 int [] node = queue .poll ();
3025 int number = node [0 ];
3126 int dist = node [1 ];
3227 if (number == numTarget ) {
3328 return dist ;
3429 }
35-
3630 int [] neighbors = getNeighbors (number );
37-
3831 for (int neighbor : neighbors ) {
3932 if (visited .contains (neighbor )) {
4033 continue ;
You can’t perform that action at this time.
0 commit comments