oranges专题

LeetCode1553. Minimum Number of Days to Eat N Oranges

文章目录 一、题目二、题解 一、题目 There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows: Eat one orange. If the number of remaining oranges n is divisible by

leetcode 994. Rotting Oranges | 994. 腐烂的橘子(BFS)

题目 https://leetcode.com/problems/rotting-oranges/ 题解 和 leetcode 542. 01 Matrix | 542. 01 矩阵(图解,广度优先搜索) 这道题几乎没有区别,直接用 542 的图,来讲一下“感染” 的过程,实际上就是个 BFS 只不过本题的 0,1,2 都被占用了,所以我们用 term=3 开始,标记感染轮数。感染过程

Leetcode 994.腐烂的橘子(Rotting Oranges)

Leetcode 994.腐烂的橘子 1 题目描述(Leetcode题目链接)   在给定的网格中,每个单元格可以有以下三个值之一: 值 0 代表空单元格;值 1 代表新鲜橘子;值 2 代表腐烂的橘子。 每分钟,任何与腐烂的橘子(在 4 个正方向上)相邻的新鲜橘子都会腐烂。返回直到单元格中没有新鲜橘子为止所必须经过的最小分钟数。如果不可能,返回 -1。 示例1: 输入:[[2,1,1]