From 887452eba8ed7b37d3167d5e839c2306668c713d Mon Sep 17 00:00:00 2001 From: yanglbme Date: Mon, 23 Dec 2024 14:03:53 +0800 Subject: [PATCH] feat: update lc problems --- .../0222.Count Complete Tree Nodes/README.md | 10 +-- .../0321.Create Maximum Number/README_EN.md | 1 + .../README.md | 1 + .../README_EN.md | 1 + .../0735.Asteroid Collision/README_EN.md | 2 +- .../0977.Squares of a Sorted Array/README.md | 12 ++-- .../1800-1899/1891.Cutting Ribbons/README.md | 2 +- .../README_EN.md | 2 +- .../README.md | 66 ++++++++++--------- .../README_EN.md | 12 ++-- solution/README.md | 4 +- solution/README_EN.md | 2 +- solution/contest.json | 2 +- 13 files changed, 61 insertions(+), 56 deletions(-) diff --git a/solution/0200-0299/0222.Count Complete Tree Nodes/README.md b/solution/0200-0299/0222.Count Complete Tree Nodes/README.md index f71300305dc27..5a348e3e973b7 100644 --- a/solution/0200-0299/0222.Count Complete Tree Nodes/README.md +++ b/solution/0200-0299/0222.Count Complete Tree Nodes/README.md @@ -21,9 +21,9 @@ tags:

给你一棵 完全二叉树 的根节点 root ,求出该树的节点个数。

-

完全二叉树 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层,则该层包含 1~ 2h 个节点。

+

完全二叉树 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 h 层(从第 0 层开始),则该层包含 1~ 2h 个节点。

-

 

+

 

示例 1:

@@ -46,17 +46,17 @@ tags: 输出:1 -

 

+

 

提示:

-

 

+

 

进阶:遍历树来统计节点是一种时间复杂度为 O(n) 的简单解决方案。你可以设计一个更快的算法吗?

diff --git a/solution/0300-0399/0321.Create Maximum Number/README_EN.md b/solution/0300-0399/0321.Create Maximum Number/README_EN.md index 16861b6a2efce..1add3a6e6a714 100644 --- a/solution/0300-0399/0321.Create Maximum Number/README_EN.md +++ b/solution/0300-0399/0321.Create Maximum Number/README_EN.md @@ -57,6 +57,7 @@ tags:
  • 1 <= m, n <= 500
  • 0 <= nums1[i], nums2[i] <= 9
  • 1 <= k <= m + n
  • +
  • nums1 and nums2 do not have leading zeros.
  • diff --git a/solution/0600-0699/0634.Find the Derangement of An Array/README.md b/solution/0600-0699/0634.Find the Derangement of An Array/README.md index b143a8adc9bf7..eeae39cb58438 100644 --- a/solution/0600-0699/0634.Find the Derangement of An Array/README.md +++ b/solution/0600-0699/0634.Find the Derangement of An Array/README.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0634.Fi tags: - 数学 - 动态规划 + - 组合数学 --- diff --git a/solution/0600-0699/0634.Find the Derangement of An Array/README_EN.md b/solution/0600-0699/0634.Find the Derangement of An Array/README_EN.md index c46550c74ab15..eb70199e1b541 100644 --- a/solution/0600-0699/0634.Find the Derangement of An Array/README_EN.md +++ b/solution/0600-0699/0634.Find the Derangement of An Array/README_EN.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0634.Fi tags: - Math - Dynamic Programming + - Combinatorics --- diff --git a/solution/0700-0799/0735.Asteroid Collision/README_EN.md b/solution/0700-0799/0735.Asteroid Collision/README_EN.md index e3baa97cce2ab..91c8b611a9712 100644 --- a/solution/0700-0799/0735.Asteroid Collision/README_EN.md +++ b/solution/0700-0799/0735.Asteroid Collision/README_EN.md @@ -18,7 +18,7 @@ tags: -

    We are given an array asteroids of integers representing asteroids in a row.

    +

    We are given an array asteroids of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space.

    For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.

    diff --git a/solution/0900-0999/0977.Squares of a Sorted Array/README.md b/solution/0900-0999/0977.Squares of a Sorted Array/README.md index 42f2dbbded508..7914c669e8f55 100644 --- a/solution/0900-0999/0977.Squares of a Sorted Array/README.md +++ b/solution/0900-0999/0977.Squares of a Sorted Array/README.md @@ -23,7 +23,7 @@ tags: -

     

    +

     

    示例 1:

    @@ -40,22 +40,22 @@ tags: 输出:[4,9,9,49,121] -

     

    +

     

    提示:

    -

     

    +

     

    进阶:

    diff --git a/solution/1800-1899/1891.Cutting Ribbons/README.md b/solution/1800-1899/1891.Cutting Ribbons/README.md index 017e46531b4a8..28f44f27eca95 100644 --- a/solution/1800-1899/1891.Cutting Ribbons/README.md +++ b/solution/1800-1899/1891.Cutting Ribbons/README.md @@ -29,7 +29,7 @@ tags:
  • 切割成四条长度为 1 的绳子。
  • -

    你的任务是找出最大 x 值,要求满足可以裁切出恰好 k 条长度均为 x 的绳子。你可以丢弃裁切后剩余的任意长度的绳子。如果不可能切割出 k 条相同长度的绳子,返回 0。

    +

    你的任务是找出最大 x 值,要求满足可以裁切出至少 k 条长度均为 x 的绳子。你可以丢弃裁切后剩余的任意长度的绳子。如果不可能切割出 k 条相同长度的绳子,返回 0。

     

    diff --git a/solution/2500-2599/2558.Take Gifts From the Richest Pile/README_EN.md b/solution/2500-2599/2558.Take Gifts From the Richest Pile/README_EN.md index 85fb5b4506dfb..ca9a70daf8698 100644 --- a/solution/2500-2599/2558.Take Gifts From the Richest Pile/README_EN.md +++ b/solution/2500-2599/2558.Take Gifts From the Richest Pile/README_EN.md @@ -25,7 +25,7 @@ tags:

    Return the number of gifts remaining after k seconds.

    diff --git a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md index 73d1970b665e9..b7de6240bc4a2 100644 --- a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md +++ b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md @@ -6,7 +6,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De -# [3391. Design a 3D Binary Matrix with Efficient Layer Tracking 🔒](https://leetcode.cn/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking) +# [3391. 设计一个高效的层跟踪三维二进制矩阵 🔒](https://leetcode.cn/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking) [English Version](/solution/3300-3399/3391.Design%20a%203D%20Binary%20Matrix%20with%20Efficient%20Layer%20Tracking/README_EN.md) @@ -14,62 +14,64 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De -

    You are given a n x n x n binary 3D array matrix.

    +

    给定一个 n x n x n 的 二进制 三维数组 matrix

    -

    Implement the matrix3D class:

    +

    实现 Matrix3D 类:

     

    -

    Example 1:

    + +

    示例 1:

    -

    Input:
    -["matrix3D", "setCell", "largestMatrix", "setCell", "largestMatrix", "setCell", "largestMatrix"]
    +

    输入:
    +["Matrix3D", "setCell", "largestMatrix", "setCell", "largestMatrix", "setCell", "largestMatrix"]
    [[3], [0, 0, 0], [], [1, 1, 2], [], [0, 0, 1], []]

    -

    Output:
    +

    输出:
    [null, null, 0, null, 1, null, 0]

    -

    Explanation

    -matrix3D matrix3D = new matrix3D(3); // Initializes a 3 x 3 x 3 3D array matrix, filled with all 0's.
    -matrix3D.setCell(0, 0, 0); // Sets matrix[0][0][0] to 1.
    -matrix3D.largestMatrix(); // Returns 0. matrix[0] has the most number of 1's.
    -matrix3D.setCell(1, 1, 2); // Sets matrix[1][1][2] to 1.
    -matrix3D.largestMatrix(); // Returns 1. matrix[0] and matrix[1] tie with the most number of 1's, but index 1 is bigger.
    -matrix3D.setCell(0, 0, 1); // Sets matrix[0][0][1] to 1.
    -matrix3D.largestMatrix(); // Returns 0. matrix[0] has the most number of 1's.
    +

    解释:

    +Matrix3D matrix3D = new Matrix3D(3); // 初始化一个 3 x 3 x 3 的三维数组 matrix,用全 0 填充。
    +matrix3D.setCell(0, 0, 0); // 将 matrix[0][0][0] 设为 1。
    +matrix3D.largestMatrix(); // 返回 0。matrix[0] 1 的数量最多。
    +matrix3D.setCell(1, 1, 2); // 将 matrix[1][1][2] 设为 1。
    +matrix3D.largestMatrix(); // 返回 1。matrix[0] 和 matrix[1] 1 的数量一样多,但下标 1 更大。
    +matrix3D.setCell(0, 0, 1); // 将 matrix[0][0][1] 设为 1。
    +matrix3D.largestMatrix(); // 返回 0。matrix[0] 1 的数量最多。 -

    Example 2:

    +

    示例 2:

    -

    Input:
    -["matrix3D", "setCell", "largestMatrix", "unsetCell", "largestMatrix"]
    +

    输入:
    +["Matrix3D", "setCell", "largestMatrix", "unsetCell", "largestMatrix"]
    [[4], [2, 1, 1], [], [2, 1, 1], []]

    -

    Output:
    +

    输出:
    [null, null, 2, null, 3]

    -

    Explanation

    -matrix3D matrix3D = new matrix3D(4); // Initializes a 4 x 4 x 4 3D array matrix, filled with all 0's.
    -matrix3D.setCell(2, 1, 1); // Sets matrix[2][1][1] to 1.
    -matrix3D.largestMatrix(); // Returns 2. matrix[2] has the most number of 1's.
    -matrix3D.unsetCell(2, 1, 1); // Sets matrix[2][1][1] to 0.
    -matrix3D.largestMatrix(); // Returns 3. All indices from 0 to 3 tie with the same number of 1's, but index 3 is the biggest.
    +

    解释:

    +Matrix3D matrix3D = new matrix3D(4); // 初始化一个 4 x 4 x 4 的三维数组 matrix,用全 0 填充。
    +matrix3D.setCell(2, 1, 1); // 将 matrix[2][1][1] 设为 1。
    +matrix3D.largestMatrix(); // 返回 2。matrix[2] 1 的数量最多。
    +matrix3D.unsetCell(2, 1, 1); // 将 matrix[2][1][1] 设为 0。
    +matrix3D.largestMatrix(); // 返回 3。0 到 3 的对应值都有相同数量的 1,但下标 3 最大。

     

    -

    Constraints:

    + +

    提示:

    diff --git a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md index 1c5a591d8dd62..8ae7154157e16 100644 --- a/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md +++ b/solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md @@ -16,10 +16,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De

    You are given a n x n x n binary 3D array matrix.

    -

    Implement the matrix3D class:

    +

    Implement the Matrix3D class: