diff --git a/solution/0100-0199/0130.Surrounded Regions/README.md b/solution/0100-0199/0130.Surrounded Regions/README.md index c349a43498a93..3711169bbd077 100644 --- a/solution/0100-0199/0130.Surrounded Regions/README.md +++ b/solution/0100-0199/0130.Surrounded Regions/README.md @@ -28,6 +28,8 @@ tags:
'X'
单元格 连接这个区域,并且区域中没有任何单元格位于 board
边缘,则该区域被 'X'
单元格围绕。通过将输入矩阵 board
中的所有 'O'
替换为 'X'
来 捕获被围绕的区域。
diff --git a/solution/0400-0499/0431.Encode N-ary Tree to Binary Tree/README.md b/solution/0400-0499/0431.Encode N-ary Tree to Binary Tree/README.md index 891dc6e22048d..cf118de586745 100644 --- a/solution/0400-0499/0431.Encode N-ary Tree to Binary Tree/README.md +++ b/solution/0400-0499/0431.Encode N-ary Tree to Binary Tree/README.md @@ -26,16 +26,47 @@ tags:
-
+
+输入:root = [1,null,3,2,4,null,5,6] ++
注意,上面的方法仅仅是一个例子,可能可行也可能不可行。你没有必要遵循这种形式转化,你可以自己创造和实现不同的方法。
-注意:
++ +
示例 1:
+ ++输入:root = [1,null,3,2,4,null,5,6] +输出:[1,null,3,2,4,null,5,6] ++ +
示例 2:
+ ++输入:root = [1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14] +输出:[1,null,2,3,4,5,null,null,6,7,null,8,null,9,10,null,null,11,null,12,null,13,null,null,14] ++ +
示例 3:
+ ++输入:root = [] +输出:[] ++ +
+ +
提示:
N
的范围在 [1, 1000]
N
的范围在 [1, 104]
0 <= Node.val <= 104
1000
。class Node { public boolean val; - public boolean isLeaf; - public Node topLeft; - public Node topRight; - public Node bottomLeft; - public Node bottomRight; + public boolean isLeaf; + public Node topLeft; + public Node topRight; + public Node bottomLeft; + public Node bottomRight; }
我们可以按以下步骤为二维区域构建四叉树:
@@ -60,9 +60,9 @@ class Node {它与二叉树的序列化非常相似。唯一的区别是节点以列表形式表示 [isLeaf, val]
。
如果 isLeaf
或者 val
的值为 True ,则表示它在列表 [isLeaf, val]
中的值为 1 ;如果 isLeaf
或者 val
的值为 False ,则表示值为 0 。
如果 isLeaf
或者 val
的值为 True ,则表示它在列表 [isLeaf, val]
中的值为 1 ;如果 isLeaf
或者 val
的值为 False ,则表示值为 0 。
+
示例 1:
@@ -88,37 +88,13 @@ class Node { 结果矩阵大小为 1*1,值全为 0 。 -示例 3:
- --输入:quadTree1 = [[0,0],[1,0],[1,0],[1,1],[1,1]] -, quadTree2 = [[0,0],[1,1],[1,1],[1,0],[1,1]] -输出:[[1,1]] -- -
示例 4:
- --输入:quadTree1 = [[0,0],[1,1],[1,0],[1,1],[1,1]] -, quadTree2 = [[0,0],[1,1],[0,1],[1,1],[1,1],null,null,null,null,[1,1],[1,0],[1,0],[1,1]] -输出:[[0,0],[1,1],[0,1],[1,1],[1,1],null,null,null,null,[1,1],[1,0],[1,0],[1,1]] -- -
示例 5:
- --输入:quadTree1 = [[0,1],[1,0],[0,1],[1,1],[1,0],null,null,null,null,[1,0],[1,0],[1,1],[1,1]] -, quadTree2 = [[0,1],[0,1],[1,0],[1,1],[1,0],[1,0],[1,0],[1,1],[1,1]] -输出:[[0,0],[0,1],[0,1],[1,1],[1,0],[1,0],[1,0],[1,1],[1,1],[1,0],[1,0],[1,1],[1,1]] -- -
+
提示:
quadTree1
和 quadTree2
都是符合题目要求的四叉树,每个都代表一个 n * n
的矩阵。n == 2^x
,其中 0 <= x <= 9
.n == 2x
,其中 0 <= x <= 9
.1000
。[0, 10^4]
之间[0, 104]
之间diff --git a/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README.md b/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README.md index 2199ea70bd3e9..21c47458df022 100644 --- a/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README.md +++ b/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README.md @@ -5,7 +5,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1600-1699/1612.Ch tags: - 树 - 深度优先搜索 + - 哈希表 - 二叉树 + - 计数 --- diff --git a/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README_EN.md b/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README_EN.md index 900d2ba2ec4b5..4297af217b4f1 100644 --- a/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README_EN.md +++ b/solution/1600-1699/1612.Check If Two Expression Trees are Equivalent/README_EN.md @@ -5,7 +5,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1600-1699/1612.Ch tags: - Tree - Depth-First Search + - Hash Table - Binary Tree + - Counting --- diff --git a/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README.md b/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README.md index b627d70c31348..46c2a2f6d59c5 100644 --- a/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README.md +++ b/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README.md @@ -5,8 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1600-1699/1625.Le rating: 1992 source: 第 211 场周赛 Q2 tags: + - 深度优先搜索 - 广度优先搜索 - 字符串 + - 枚举 --- diff --git a/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README_EN.md b/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README_EN.md index 6f4cd47f3bedd..93fbdf73b2432 100644 --- a/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README_EN.md +++ b/solution/1600-1699/1625.Lexicographically Smallest String After Applying Operations/README_EN.md @@ -5,8 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1600-1699/1625.Le rating: 1992 source: Weekly Contest 211 Q2 tags: + - Depth-First Search - Breadth-First Search - String + - Enumeration --- diff --git a/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README.md b/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README.md index ec3919c0c1466..2288b3815533c 100644 --- a/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README.md +++ b/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README.md @@ -6,6 +6,7 @@ tags: - 栈 - 树 - 设计 + - 数组 - 数学 - 二叉树 --- diff --git a/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README_EN.md b/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README_EN.md index 938ba824d3fd7..1934da2fa2231 100644 --- a/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README_EN.md +++ b/solution/1600-1699/1628.Design an Expression Tree With Evaluate Function/README_EN.md @@ -6,6 +6,7 @@ tags: - Stack - Tree - Design + - Array - Math - Binary Tree --- diff --git a/solution/1600-1699/1638.Count Substrings That Differ by One Character/README.md b/solution/1600-1699/1638.Count Substrings That Differ by One Character/README.md index ea2ad082ae243..206abc3120c8a 100644 --- a/solution/1600-1699/1638.Count Substrings That Differ by One Character/README.md +++ b/solution/1600-1699/1638.Count Substrings That Differ by One Character/README.md @@ -8,6 +8,7 @@ tags: - 哈希表 - 字符串 - 动态规划 + - 枚举 --- diff --git a/solution/1600-1699/1638.Count Substrings That Differ by One Character/README_EN.md b/solution/1600-1699/1638.Count Substrings That Differ by One Character/README_EN.md index a5f65c97d2e07..25a42ac17a2a3 100644 --- a/solution/1600-1699/1638.Count Substrings That Differ by One Character/README_EN.md +++ b/solution/1600-1699/1638.Count Substrings That Differ by One Character/README_EN.md @@ -8,6 +8,7 @@ tags: - Hash Table - String - Dynamic Programming + - Enumeration --- diff --git a/solution/2600-2699/2644.Find the Maximum Divisibility Score/README.md b/solution/2600-2699/2644.Find the Maximum Divisibility Score/README.md index d4d7b6f5882e6..d915e2ac4716e 100644 --- a/solution/2600-2699/2644.Find the Maximum Divisibility Score/README.md +++ b/solution/2600-2699/2644.Find the Maximum Divisibility Score/README.md @@ -37,13 +37,13 @@ tags:
divisors[0]
的可整除性分数为 2 因为 nums[2]
和 nums[3]
能被 5 整除。
divisors[1]
的可整除性分数为 1 因为只有 nums[1]
能被 3 整除。
divisors[1]
的可整除性分数为 2 因为 nums[1]
和 nums[2]
能被 3 整除。
divisors[2]
的可整除性分数为 0 因为 nums
中没有数字能被 7 整除。
divisors[3]
的可整除性分数为 2 因为 nums[0]
和 nums[3]
能够被 2 整除。
因为 divisors[0]
和 divisors[3]
有相同的可整除性分数,我们返回更小的那个 divisors[3]
。
因为 divisors[0]
、divisor[1]
和 divisors[3]
有相同的可整除性分数,我们返回更小的那个 divisors[3]
。
示例 2:
@@ -71,13 +71,13 @@ tags:解释:
-divisors[0]
的可整除性分数为 0 因为 nums
中没有数字能被 10 整除。
divisors[0]
的可整除性分数为 2 因为 nums[0]
和 nums[3]
能被 10 整除。
divisors[1]
的可整除性分数为 0 因为 nums
中没有数字能被 16 整除。
divisors[2]
的可整除性分数为 0 因为 nums
中没有数字能被 20 整除。
divisors[2]
的可整除性分数为 1 因为 nums[0]
能被 20 整除。
因为 divisors[0]
,divisors[1]
和 divisors[2]
都有相同的可整除性分数,我们返回最小的那个 divisors[0]
。
因为 divisors[0]
的可整除性分数最大,我们返回 divisors[0]
。
diff --git a/solution/2600-2699/2644.Find the Maximum Divisibility Score/README_EN.md b/solution/2600-2699/2644.Find the Maximum Divisibility Score/README_EN.md index 615116835685c..7e91b0cdf7fc2 100644 --- a/solution/2600-2699/2644.Find the Maximum Divisibility Score/README_EN.md +++ b/solution/2600-2699/2644.Find the Maximum Divisibility Score/README_EN.md @@ -36,13 +36,13 @@ tags:
The divisibility score of divisors[0]
is 2 since nums[2]
and nums[3]
are divisible by 5.
The divisibility score of divisors[1]
is 1 since only nums[1]
is divisible by 3.
The divisibility score of divisors[1]
is 2 since nums[1]
and nums[2]
are divisible by 3.
The divisibility score of divisors[2]
is 0 since none of the numbers in nums
is divisible by 7.
The divisibility score of divisors[3]
is 2 since nums[0]
and nums[3]
are divisible by 2.
As divisors[0]
and divisors[3]
have the same divisibility score, we return the smaller one which is divisors[3]
.
As divisors[0]
, divisors[1]
, and divisors[3]
have the same divisibility score, we return the smaller one which is divisors[3]
.
Example 2:
@@ -70,13 +70,11 @@ tags:Explanation:
-The divisibility score of divisors[0]
is 0 since none of the numbers in nums
is divisible by 10.
The divisibility score of divisors[0]
is 2 since nums[0]
and nums[3]
are divisible by 10.
The divisibility score of divisors[1]
is 0 since none of the numbers in nums
is divisible by 16.
The divisibility score of divisors[2]
is 0 since none of the numbers in nums
is divisible by 20.
As divisors[0]
, divisors[1]
and divisors[2]
all have the same divisibility score, we return the smallest one which is divisors[0]
.
The divisibility score of divisors[2]
is 1 since nums[0]
is divisible by 20.
diff --git a/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README.md b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README.md index 4667f6f59b37b..156ce91fde6a3 100644 --- a/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README.md +++ b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README.md @@ -82,7 +82,17 @@ tags: -### 方法一 +### 方法一:排序 + 动态规划 + +根据题目描述,我们顺序移动的单元格的值必须严格递增,因此,我们不妨用一个哈希表 $g$ 来记录每个值对应的所有单元格的位置,然后按照值的大小从小到大遍历。 + +在这个过程中,我们可以维护两个数组 `rowMax` 和 `colMax`,分别记录每一行和每一列的最大递增长度。初始时,这两个数组的所有元素都为 $0$。 + +对于每个值对应的所有单元格位置,我们按照位置顺序遍历,对于每个位置 $(i, j)$,我们可以计算出以该位置为终点的最大递增长度为 $1 + \max(\text{rowMax}[i], \text{colMax}[j])$,更新答案,然后更新 `rowMax[i]` 和 `colMax[j]`。 + +最后返回答案即可。 + +时间复杂度 $O(m \times n \times \log(m \times n))$,空间复杂度 $O(m \times n)$。 @@ -212,6 +222,51 @@ func maxIncreasingCells(mat [][]int) (ans int) { } ``` +#### TypeScript + +```ts +function maxIncreasingCells(mat: number[][]): number { + const m = mat.length; + const n = mat[0].length; + const g: { [key: number]: [number, number][] } = {}; + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (!g[mat[i][j]]) { + g[mat[i][j]] = []; + } + g[mat[i][j]].push([i, j]); + } + } + + const rowMax = Array(m).fill(0); + const colMax = Array(n).fill(0); + let ans = 0; + + const sortedKeys = Object.keys(g) + .map(Number) + .sort((a, b) => a - b); + + for (const key of sortedKeys) { + const pos = g[key]; + const mx: number[] = []; + + for (const [i, j] of pos) { + mx.push(1 + Math.max(rowMax[i], colMax[j])); + ans = Math.max(ans, mx[mx.length - 1]); + } + + for (let k = 0; k < pos.length; k++) { + const [i, j] = pos[k]; + rowMax[i] = Math.max(rowMax[i], mx[k]); + colMax[j] = Math.max(colMax[j], mx[k]); + } + } + + return ans; +} +``` + diff --git a/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README_EN.md b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README_EN.md index a633028d39fdd..00a2665eeb8f1 100644 --- a/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README_EN.md +++ b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/README_EN.md @@ -81,7 +81,17 @@ tags: -### Solution 1 +### Solution 1: Sorting + Dynamic Programming + +Based on the problem description, the value of the cells we move through in sequence must strictly increase. Therefore, we can use a hash table $g$ to record the positions of all cells corresponding to each value, and then traverse from the smallest to the largest value. + +During this process, we can maintain two arrays `rowMax` and `colMax`, which record the maximum increasing length of each row and column, respectively. Initially, all elements of these two arrays are $0$. + +For all cell positions corresponding to each value, we traverse them in order of position. For each position $(i, j)$, we can calculate the maximum increasing length ending at that position as $1 + \max(\text{rowMax}[i], \text{colMax}[j])$, update the answer, and then update `rowMax[i]` and `colMax[j]`. + +Finally, return the answer. + +The time complexity is $O(m \times n \times \log(m \times n))$, and the space complexity is $O(m \times n)$. @@ -211,6 +221,51 @@ func maxIncreasingCells(mat [][]int) (ans int) { } ``` +#### TypeScript + +```ts +function maxIncreasingCells(mat: number[][]): number { + const m = mat.length; + const n = mat[0].length; + const g: { [key: number]: [number, number][] } = {}; + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (!g[mat[i][j]]) { + g[mat[i][j]] = []; + } + g[mat[i][j]].push([i, j]); + } + } + + const rowMax = Array(m).fill(0); + const colMax = Array(n).fill(0); + let ans = 0; + + const sortedKeys = Object.keys(g) + .map(Number) + .sort((a, b) => a - b); + + for (const key of sortedKeys) { + const pos = g[key]; + const mx: number[] = []; + + for (const [i, j] of pos) { + mx.push(1 + Math.max(rowMax[i], colMax[j])); + ans = Math.max(ans, mx[mx.length - 1]); + } + + for (let k = 0; k < pos.length; k++) { + const [i, j] = pos[k]; + rowMax[i] = Math.max(rowMax[i], mx[k]); + colMax[j] = Math.max(colMax[j], mx[k]); + } + } + + return ans; +} +``` + diff --git a/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/Solution.ts b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/Solution.ts new file mode 100644 index 0000000000000..bc001aee88854 --- /dev/null +++ b/solution/2700-2799/2713.Maximum Strictly Increasing Cells in a Matrix/Solution.ts @@ -0,0 +1,40 @@ +function maxIncreasingCells(mat: number[][]): number { + const m = mat.length; + const n = mat[0].length; + const g: { [key: number]: [number, number][] } = {}; + + for (let i = 0; i < m; i++) { + for (let j = 0; j < n; j++) { + if (!g[mat[i][j]]) { + g[mat[i][j]] = []; + } + g[mat[i][j]].push([i, j]); + } + } + + const rowMax = Array(m).fill(0); + const colMax = Array(n).fill(0); + let ans = 0; + + const sortedKeys = Object.keys(g) + .map(Number) + .sort((a, b) => a - b); + + for (const key of sortedKeys) { + const pos = g[key]; + const mx: number[] = []; + + for (const [i, j] of pos) { + mx.push(1 + Math.max(rowMax[i], colMax[j])); + ans = Math.max(ans, mx[mx.length - 1]); + } + + for (let k = 0; k < pos.length; k++) { + const [i, j] = pos[k]; + rowMax[i] = Math.max(rowMax[i], mx[k]); + colMax[j] = Math.max(colMax[j], mx[k]); + } + } + + return ans; +} diff --git a/solution/2700-2799/2732.Find a Good Subset of the Matrix/README.md b/solution/2700-2799/2732.Find a Good Subset of the Matrix/README.md index a9bfc7cfac906..215f07dba3821 100644 --- a/solution/2700-2799/2732.Find a Good Subset of the Matrix/README.md +++ b/solution/2700-2799/2732.Find a Good Subset of the Matrix/README.md @@ -5,9 +5,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2700-2799/2732.Fi rating: 2239 source: 第 106 场双周赛 Q4 tags: - - 贪心 - 位运算 - 数组 + - 哈希表 - 矩阵 --- diff --git a/solution/2700-2799/2732.Find a Good Subset of the Matrix/README_EN.md b/solution/2700-2799/2732.Find a Good Subset of the Matrix/README_EN.md index 2289f662722e2..d3dd728330d2d 100644 --- a/solution/2700-2799/2732.Find a Good Subset of the Matrix/README_EN.md +++ b/solution/2700-2799/2732.Find a Good Subset of the Matrix/README_EN.md @@ -5,9 +5,9 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2700-2799/2732.Fi rating: 2239 source: Biweekly Contest 106 Q4 tags: - - Greedy - Bit Manipulation - Array + - Hash Table - Matrix --- diff --git a/solution/2700-2799/2748.Number of Beautiful Pairs/README.md b/solution/2700-2799/2748.Number of Beautiful Pairs/README.md index bb9ceeded64b0..bc93f9b4588e9 100644 --- a/solution/2700-2799/2748.Number of Beautiful Pairs/README.md +++ b/solution/2700-2799/2748.Number of Beautiful Pairs/README.md @@ -6,7 +6,9 @@ rating: 1301 source: 第 351 场周赛 Q1 tags: - 数组 + - 哈希表 - 数学 + - 计数 - 数论 --- diff --git a/solution/2700-2799/2748.Number of Beautiful Pairs/README_EN.md b/solution/2700-2799/2748.Number of Beautiful Pairs/README_EN.md index bce8938de3f38..0ef54ca10efaa 100644 --- a/solution/2700-2799/2748.Number of Beautiful Pairs/README_EN.md +++ b/solution/2700-2799/2748.Number of Beautiful Pairs/README_EN.md @@ -6,7 +6,9 @@ rating: 1301 source: Weekly Contest 351 Q1 tags: - Array + - Hash Table - Math + - Counting - Number Theory --- diff --git a/solution/2800-2899/2847.Smallest Number With Given Digit Product/README.md b/solution/2800-2899/2847.Smallest Number With Given Digit Product/README.md index 895f2aa154e30..9870f783dc479 100644 --- a/solution/2800-2899/2847.Smallest Number With Given Digit Product/README.md +++ b/solution/2800-2899/2847.Smallest Number With Given Digit Product/README.md @@ -17,7 +17,7 @@ tags: -
给定一个 正 整数 n
,返回一个字符串,表示 最小的正整数,使其各位数字的乘积等于 n
,如果不存在这样的数字,则返回 "-1"
。
给定一个 正 整数 n
,返回一个字符串,表示使其各位数字的乘积等于 n
的 最小正整数,如果不存在这样的数字,则返回 "-1"
。
@@ -26,7 +26,7 @@ tags:
输入:n = 105 输出:"357" -解释:3 * 5 * 7 = 105。可以证明,357 是乘积等于 105 的最小数字。因此答案为 "105"。 +解释:3 * 5 * 7 = 105。可以证明,357 是各位数字的乘积等于 105 的最小数字。因此答案为 "357"。
示例 2:
diff --git a/solution/2800-2899/2852.Sum of Remoteness of All Cells/README.md b/solution/2800-2899/2852.Sum of Remoteness of All Cells/README.md index 675a820223870..78abeee82b591 100644 --- a/solution/2800-2899/2852.Sum of Remoteness of All Cells/README.md +++ b/solution/2800-2899/2852.Sum of Remoteness of All Cells/README.md @@ -7,6 +7,7 @@ tags: - 广度优先搜索 - 并查集 - 数组 + - 哈希表 - 矩阵 --- diff --git a/solution/2800-2899/2852.Sum of Remoteness of All Cells/README_EN.md b/solution/2800-2899/2852.Sum of Remoteness of All Cells/README_EN.md index f73d388e39a54..803ce6456d44f 100644 --- a/solution/2800-2899/2852.Sum of Remoteness of All Cells/README_EN.md +++ b/solution/2800-2899/2852.Sum of Remoteness of All Cells/README_EN.md @@ -7,6 +7,7 @@ tags: - Breadth-First Search - Union Find - Array + - Hash Table - Matrix --- diff --git a/solution/2900-2999/2944.Minimum Number of Coins for Fruits/README.md b/solution/2900-2999/2944.Minimum Number of Coins for Fruits/README.md index 93ca41840e3c9..a5fdf8b774601 100644 --- a/solution/2900-2999/2944.Minimum Number of Coins for Fruits/README.md +++ b/solution/2900-2999/2944.Minimum Number of Coins for Fruits/README.md @@ -29,7 +29,7 @@ tags:水果超市有如下促销活动:
price[i]
购买了水果 i
,那么你可以免费获得接下来的 (i + 1)
个水果中任意数量的水果。price[i]
购买了下标为 i
的水果,那么你可以免费获得下标范围在 [i + 1, i + i]
的水果。注意 ,即使你 可以 免费获得水果 j
,你仍然可以花费 prices[j]
个金币去购买它以获得它的奖励。