Skip to content

docs: add a description of the solution to lc problem: No.0994 #727

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions solution/0900-0999/0994.Rotting Oranges/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,18 @@

<!-- 这里可写通用的实现逻辑 -->

首先需要确定的是,网格当中存在多少个新鲜橘子,这关系到什么时候结束。

其次,腐烂橘子的坐标在哪,这些坐标要作为中心点,将腐烂传播给四方的新鲜橘子。

步骤:

1. 扫描网格,统计新鲜橘子的数量,记录腐烂橘子的坐标。
2. 如果新鲜橘子的数量为 0,返回重复 2 - 5 步骤的轮数(也就是分钟)。
3. 如果不存在**有效**的腐烂橘子,而现存的新鲜橘子不为 0,则为不可能,返回 -1。
4. 遍历当前已记录的腐烂橘子,将四方的新鲜橘子污染。如果有新鲜橘子被污染成功,便记录该橘子的坐标,在下一轮使用(不参与本轮行动)。
5. 回到第 2 步。

<!-- tabs:start -->

### **Python3**
Expand Down