Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4ad6095

Browse files
authored
Improved task 864.
1 parent 509a013 commit 4ad6095

File tree

1 file changed

+4
-6
lines changed
  • src/main/java/g0801_0900/s0864_shortest_path_to_get_all_keys

1 file changed

+4
-6
lines changed

‎src/main/java/g0801_0900/s0864_shortest_path_to_get_all_keys/Solution.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import java.util.LinkedList;
66
import java.util.Queue;
77

8-
@SuppressWarnings("java:S135")
98
public class Solution {
109
private int m;
1110
private int n;
@@ -76,11 +75,10 @@ public int shortestPathAllKeys(String[] stringGrid) {
7675
// use & to see if we have the key
7776
// 0 means that the digit we are looking at is 0
7877
// need a 1 at the digit spot which means there is a key there
79-
if ('A' <= grid[nx][ny]
80-
&& grid[nx][ny] <= 'F'
81-
&& ((nState & (1 << (grid[nx][ny] - 'A'))) == 0)) {
82-
continue;
83-
} else if (!visited[nx][ny][nState]) {
78+
if (('A' > grid[nx][ny]
79+
|| grid[nx][ny] > 'F'
80+
|| ((nState & (1 << (grid[nx][ny] - 'A'))) != 0))
81+
&& !visited[nx][ny][nState]) {
8482
q.add(new int[] {nx, ny, nState});
8583
visited[nx][ny][nState] = true;
8684
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /