8000 update 994 · githubniraj/Leetcode@45db5b3 · GitHub
[go: up one dir, main page]

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

< 8000 div class="position-relative HeaderMenu-link-wrap d-lg-inline-block">
Appearance settings

Commit 45db5b3

Browse files
update 994
1 parent ee74fa9 commit 45db5b3

File tree

1 file changed

+4
-6
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-6
lines changed

src/main/java/com/fishercoder/solutions/_994.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@ public int orangesRotting(int[][] grid) {
6767
}
6868
}
6969
}
70-
int min = 0;
70+
int time = 0;
7171
int[] directions = new int[]{0, 1, 0, -1, 0};
7272
while (!queue.isEmpty() && !fresh.isEmpty()) {
7373
int size = queue.size();
74-
if (size > 0) {
75-
min++;
76-
}
74+
time++;
7775
for (int i = 0; i < size; i++) {
7876
int[] curr = queue.poll();
7977
for (int k = 0; k < directions.length - 1; k++) {
@@ -82,15 +80,15 @@ public int orangesRotting(int[][] grid) {
8280
if (nextX >= 0 && nextX < m && nextY >= 0 && nextY < n && grid[nextX][nextY] == 1) {
8381
fresh.remove(nextX * n + nextY);
8482
if (fresh.isEmpty()) {
85-
return min;
83+
return time;
8684
}
8785
grid[nextX][nextY] = 2;
8886
queue.offer(new int[]{nextX, nextY});
8987
}
9088
}
9189
}
9290
}
93-
return fresh.isEmpty() ? min : -1;
91+
return fresh.isEmpty() ? time : -1;
9492
}
9593
}
9694

0 commit comments

Comments
 (0)
0