diff --git a/solution/0200-0299/0277.Find the Celebrity/README_EN.md b/solution/0200-0299/0277.Find the Celebrity/README_EN.md index 56be8c2410d0a..b69073887df63 100644 --- a/solution/0200-0299/0277.Find the Celebrity/README_EN.md +++ b/solution/0200-0299/0277.Find the Celebrity/README_EN.md @@ -22,10 +22,12 @@ tags:

Now you want to find out who the celebrity is or verify that there is not one. You are only allowed to ask questions like: "Hi, A. Do you know B?" to get information about whether A knows B. You need to find out the celebrity (or verify there is not one) by asking as few questions as possible (in the asymptotic sense).

-

You are given a helper function bool knows(a, b) that tells you whether a knows b. Implement a function int findCelebrity(n). There will be exactly one celebrity if they are at the party.

+

You are given an integer n and a helper function bool knows(a, b) that tells you whether a knows b. Implement a function int findCelebrity(n). There will be exactly one celebrity if they are at the party.

Return the celebrity's label if there is a celebrity at the party. If there is no celebrity, return -1.

+

Note that the n x n 2D array graph given as input is not directly available to you, and instead only accessible through the helper function knows. graph[i][j] == 1 represents person i knows person j, wherease graph[i][j] == 0 represents person j does not know person i.

+

 

Example 1:

diff --git a/solution/0300-0399/0364.Nested List Weight Sum II/README.md b/solution/0300-0399/0364.Nested List Weight Sum II/README.md index b211f0779c411..b86878aa336be 100644 --- a/solution/0300-0399/0364.Nested List Weight Sum II/README.md +++ b/solution/0300-0399/0364.Nested List Weight Sum II/README.md @@ -54,6 +54,7 @@ tags:
  • 1 <= nestedList.length <= 50
  • 嵌套列表中整数的值在范围 [-100, 100]
  • 任意整数的最大 深度 小于等于 50
  • +
  • 没有空列表
  • diff --git a/solution/0300-0399/0364.Nested List Weight Sum II/README_EN.md b/solution/0300-0399/0364.Nested List Weight Sum II/README_EN.md index 4ca8f0301878d..819919fa706ce 100644 --- a/solution/0300-0399/0364.Nested List Weight Sum II/README_EN.md +++ b/solution/0300-0399/0364.Nested List Weight Sum II/README_EN.md @@ -52,6 +52,7 @@ tags:
  • 1 <= nestedList.length <= 50
  • The values of the integers in the nested list is in the range [-100, 100].
  • The maximum depth of any integer is less than or equal to 50.
  • +
  • There are no empty lists.
  • diff --git a/solution/0700-0799/0773.Sliding Puzzle/README.md b/solution/0700-0799/0773.Sliding Puzzle/README.md index 4e70bf616f549..5f39db97cc095 100644 --- a/solution/0700-0799/0773.Sliding Puzzle/README.md +++ b/solution/0700-0799/0773.Sliding Puzzle/README.md @@ -4,7 +4,10 @@ difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/0700-0799/0773.Sliding%20Puzzle/README.md tags: - 广度优先搜索 + - 记忆化搜索 - 数组 + - 动态规划 + - 回溯 - 矩阵 --- diff --git a/solution/0700-0799/0773.Sliding Puzzle/README_EN.md b/solution/0700-0799/0773.Sliding Puzzle/README_EN.md index 389533e755937..5cd6b38557b48 100644 --- a/solution/0700-0799/0773.Sliding Puzzle/README_EN.md +++ b/solution/0700-0799/0773.Sliding Puzzle/README_EN.md @@ -4,7 +4,10 @@ difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/0700-0799/0773.Sliding%20Puzzle/README_EN.md tags: - Breadth-First Search + - Memoization - Array + - Dynamic Programming + - Backtracking - Matrix --- diff --git a/solution/0700-0799/0782.Transform to Chessboard/README.md b/solution/0700-0799/0782.Transform to Chessboard/README.md index 3dfccbe0d1153..45142a406af4e 100644 --- a/solution/0700-0799/0782.Transform to Chessboard/README.md +++ b/solution/0700-0799/0782.Transform to Chessboard/README.md @@ -19,7 +19,7 @@ tags: -

    一个 n x n 的二维网络 board 仅由 0 和 1 组成 。每次移动,你能任意交换两列或是两行的位置。

    +

    一个 n x n 的二维网络 board 仅由 0 和 1 组成 。每次移动,你能交换任意两列或是两行的位置。

    返回 将这个矩阵变为  “棋盘”  所需的最小移动次数 。如果不存在可行的变换,输出 -1

    diff --git a/solution/1600-1699/1683.Invalid Tweets/README.md b/solution/1600-1699/1683.Invalid Tweets/README.md index fdecfc9fb2bbe..a23ad08ee10e2 100644 --- a/solution/1600-1699/1683.Invalid Tweets/README.md +++ b/solution/1600-1699/1683.Invalid Tweets/README.md @@ -26,6 +26,7 @@ tags: | content | varchar | +----------------+---------+ 在 SQL 中,tweet_id 是这个表的主键。 +content 只包含美式键盘上的字符,不包含其它特殊字符。 这个表包含某社交媒体 App 中所有的推文。

     

    diff --git a/solution/1600-1699/1683.Invalid Tweets/README_EN.md b/solution/1600-1699/1683.Invalid Tweets/README_EN.md index 322780b87a293..9b40b39e72e7a 100644 --- a/solution/1600-1699/1683.Invalid Tweets/README_EN.md +++ b/solution/1600-1699/1683.Invalid Tweets/README_EN.md @@ -26,6 +26,7 @@ tags: | content | varchar | +----------------+---------+ tweet_id is the primary key (column with unique values) for this table. +content consists of characters on an American Keyboard, and no other special characters. This table contains all the tweets in a social media app. diff --git a/solution/1800-1899/1861.Rotating the Box/README.md b/solution/1800-1899/1861.Rotating the Box/README.md index d8b5644af7adb..582727d21134d 100644 --- a/solution/1800-1899/1861.Rotating the Box/README.md +++ b/solution/1800-1899/1861.Rotating the Box/README.md @@ -20,68 +20,71 @@ tags: -

    给你一个 m x n 的字符矩阵 box ,它表示一个箱子的侧视图。箱子的每一个格子可能为:

    +

    给你一个 m x n 的字符矩阵 boxGrid ,它表示一个箱子的侧视图。箱子的每一个格子可能为:

    -

    这个箱子被 顺时针旋转 90 度 ,由于重力原因,部分石头的位置会发生改变。每个石头会垂直掉落,直到它遇到障碍物,另一个石头或者箱子的底部。重力 不会 影响障碍物的位置,同时箱子旋转不会产生惯性 ,也就是说石头的水平位置不会发生改变。

    +

    这个箱子被 顺时针旋转 90 度 ,由于重力原因,部分石头的位置会发生改变。每个石头会垂直掉落,直到它遇到障碍物,另一个石头或者箱子的底部。重力 不会 影响障碍物的位置,同时箱子旋转不会产生惯性 ,也就是说石头的水平位置不会发生改变。

    -

    题目保证初始时 box 中的石头要么在一个障碍物上,要么在另一个石头上,要么在箱子的底部。

    +

    题目保证初始时 boxGrid 中的石头要么在一个障碍物上,要么在另一个石头上,要么在箱子的底部。

    -

    请你返回一个 n x m的矩阵,表示按照上述旋转后,箱子内的结果。

    +

    请你返回一个 n x m 的矩阵,表示按照上述旋转后,箱子内的结果。

    -

     

    +

     

    示例 1:

    -

    +

    -
    输入:box = [["#",".","#"]]
    +
    +输入:box = [["#",".","#"]]
     输出:[["."],
    -      ["#"],
    -      ["#"]]
    +      ["#"],
    +      ["#"]]
     

    示例 2:

    -

    +

    -
    输入:box = [["#",".","*","."],
    -            ["#","#","*","."]]
    +
    +输入:box = [["#",".","*","."],
    +            ["#","#","*","."]]
     输出:[["#","."],
    -      ["#","#"],
    -      ["*","*"],
    -      [".","."]]
    +      ["#","#"],
    +      ["*","*"],
    +      [".","."]]
     

    示例 3:

    -

    +

    -
    输入:box = [["#","#","*",".","*","."],
    -            ["#","#","#","*",".","."],
    -            ["#","#","#",".","#","."]]
    +
    +输入:box = [["#","#","*",".","*","."],
    +            ["#","#","#","*",".","."],
    +            ["#","#","#",".","#","."]]
     输出:[[".","#","#"],
    -      [".","#","#"],
    -      ["#","#","*"],
    -      ["#","*","."],
    -      ["#",".","*"],
    -      ["#",".","."]]
    +      [".","#","#"],
    +      ["#","#","*"],
    +      ["#","*","."],
    +      ["#",".","*"],
    +      ["#",".","."]]
     
    -

     

    +

     

    提示:

      -
    • m == box.length
    • -
    • n == box[i].length
    • +
    • m == boxGrid.length
    • +
    • n == boxGrid[i].length
    • 1 <= m, n <= 500
    • -
    • box[i][j] 只可能是 '#' ,'*' 或者 '.' 。
    • +
    • boxGrid[i][j] 只可能是 '#' ,'*' 或者 '.' 。
    diff --git a/solution/1800-1899/1861.Rotating the Box/README_EN.md b/solution/1800-1899/1861.Rotating the Box/README_EN.md index 9c61ff85d9f6c..3c58cf3f9ab05 100644 --- a/solution/1800-1899/1861.Rotating the Box/README_EN.md +++ b/solution/1800-1899/1861.Rotating the Box/README_EN.md @@ -20,40 +20,30 @@ tags: -

    You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following:

    +

    You are given an m x n matrix of characters boxGrid representing a side-view of a box. Each cell of the box is one of the following:

      - -
    • A stone '#'
    • - -
    • A stationary obstacle '*'
    • - -
    • Empty '.'
    • - +
    • A stone '#'
    • +
    • A stationary obstacle '*'
    • +
    • Empty '.'

    The box is rotated 90 degrees clockwise, causing some of the stones to fall due to gravity. Each stone falls down until it lands on an obstacle, another stone, or the bottom of the box. Gravity does not affect the obstacles' positions, and the inertia from the box's rotation does not affect the stones' horizontal positions.

    -

    It is guaranteed that each stone in box rests on an obstacle, another stone, or the bottom of the box.

    +

    It is guaranteed that each stone in boxGrid rests on an obstacle, another stone, or the bottom of the box.

    Return an n x m matrix representing the box after the rotation described above.

     

    -

    Example 1:

    -
    -Input: box = [["#",".","#"]]
    -
    +Input: boxGrid = [["#",".","#"]]
     Output: [["."],
    -
              ["#"],
    -
              ["#"]]
    -
     

    Example 2:

    @@ -61,19 +51,12 @@ tags:

    -
    -Input: box = [["#",".","*","."],
    -
    +Input: boxGrid = [["#",".","*","."],
                   ["#","#","*","."]]
    -
     Output: [["#","."],
    -
              ["#","#"],
    -
              ["*","*"],
    -
              [".","."]]
    -
     

    Example 3:

    @@ -81,41 +64,25 @@ tags:

    -
    -Input: box = [["#","#","*",".","*","."],
    -
    +Input: boxGrid = [["#","#","*",".","*","."],
                   ["#","#","#","*",".","."],
    -
                   ["#","#","#",".","#","."]]
    -
     Output: [[".","#","#"],
    -
              [".","#","#"],
    -
              ["#","#","*"],
    -
              ["#","*","."],
    -
              ["#",".","*"],
    -
              ["#",".","."]]
    -
     

     

    -

    Constraints:

      - -
    • m == box.length
    • - -
    • n == box[i].length
    • - -
    • 1 <= m, n <= 500
    • - -
    • box[i][j] is either '#', '*', or '.'.
    • - +
    • m == boxGrid.length
    • +
    • n == boxGrid[i].length
    • +
    • 1 <= m, n <= 500
    • +
    • boxGrid[i][j] is either '#', '*', or '.'.
    diff --git a/solution/1800-1899/1891.Cutting Ribbons/README.md b/solution/1800-1899/1891.Cutting Ribbons/README.md index 5d665cf2d6573..017e46531b4a8 100644 --- a/solution/1800-1899/1891.Cutting Ribbons/README.md +++ b/solution/1800-1899/1891.Cutting Ribbons/README.md @@ -17,27 +17,26 @@ tags: -

    给定一个整数数组 ribbons 和一个整数 k,数组每项 ribbons[i] 表示第 i 条绳子的长度。对于每条绳子,你可以将任意切割成一系列长度为正整数的部分,或者选择不进行切割。

    +

    给定一个整数数组 ribbons 和一个整数 k,数组每项 ribbons[i] 表示第 i 条绳子的长度。对于每条绳子,你可以将任意切割成一系列长度为 正整数 的部分,或者选择不进行切割。

    例如,如果给你一条长度为 4 的绳子,你可以:

    • 保持绳子的长度为 4 不变;
    • 切割成一条长度为 3 和一条长度为 1 的绳子;
    • -
    • 切割成两条长度为 2 的绳子;
    • -
    • 切割成一条长度为 2 和两条长度为 1 的绳子;
    • -
    • 切割成四条长度为 1 的绳子。
    • +
    • 切割成两条长度为 2 的绳子;
    • +
    • 切割成一条长度为 2 和两条长度为 1 的绳子;
    • +
    • 切割成四条长度为 1 的绳子。
    -

    你的任务是最终得到 k 条完全一样的绳子,他们的长度均为相同的正整数。如果绳子切割后有剩余,你可以直接舍弃掉多余的部分。

    +

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

    -

    对于这 k 根绳子,返回你能得到的绳子最大长度;如果你无法得到 k 根相同长度的绳子,返回 0

    - -

     

    +

     

    示例 1:

    -
    输入: ribbons = [9,7,5], k = 3
    +
    +输入: ribbons = [9,7,5], k = 3
     输出: 5
     解释:
     - 把第一条绳子切成两部分,一条长度为 5,一条长度为 4;
    @@ -47,7 +46,8 @@ tags:
     
     

    示例 2:

    -
    输入: ribbons = [7,5,9], k = 4
    +
    +输入: ribbons = [7,5,9], k = 4
     输出: 4
     解释:
     - 把第一条绳子切成两部分,一条长度为 4,一条长度为 3;
    @@ -58,12 +58,13 @@ tags:
     
     

    示例 3:

    -
    输入: ribbons = [5,7,9], k = 22
    +
    +输入: ribbons = [5,7,9], k = 22
     输出: 0
     解释: 由于绳子长度需要为正整数,你无法得到 22 条长度相同的绳子。
     
    -

     

    +

     

    提示:

    diff --git a/solution/1800-1899/1891.Cutting Ribbons/README_EN.md b/solution/1800-1899/1891.Cutting Ribbons/README_EN.md index f7767d80e310b..569ce99a275b7 100644 --- a/solution/1800-1899/1891.Cutting Ribbons/README_EN.md +++ b/solution/1800-1899/1891.Cutting Ribbons/README_EN.md @@ -33,9 +33,7 @@ tags: -

    Your goal is to obtain k ribbons of all the same positive integer length. You are allowed to throw away any excess ribbon as a result of cutting.

    - -

    Return the maximum possible positive integer length that you can obtain k ribbons of, or 0 if you cannot obtain k ribbons of the same length.

    +

    Your task is to determine the maximum length of ribbon, x, that allows you to cut exactly k ribbons, each of length x. You can discard any leftover ribbon from the cuts. If it is impossible to cut k ribbons of the same length, return 0.

     

    Example 1:

    diff --git a/solution/2000-2099/2056.Number of Valid Move Combinations On Chessboard/README.md b/solution/2000-2099/2056.Number of Valid Move Combinations On Chessboard/README.md index 5dc8e5547bfac..e64a42540f4ee 100644 --- a/solution/2000-2099/2056.Number of Valid Move Combinations On Chessboard/README.md +++ b/solution/2000-2099/2056.Number of Valid Move Combinations On Chessboard/README.md @@ -115,7 +115,7 @@ tags:
  • n == positions.length
  • 1 <= n <= 4
  • pieces 只包含字符串 "rook" ,"queen" 和 "bishop" 。
  • -
  • 棋盘上总共最多只有一个后。
  • +
  • 棋盘上最多只有一个后。
  • 1 <= ri, ci <= 8
  • 每一个 positions[i] 互不相同。
  • diff --git a/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README.md b/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README.md index 86d39b86ebe63..c2e1244015eaf 100644 --- a/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README.md +++ b/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2000-2099/2064.Mi rating: 1885 source: 第 266 场周赛 Q3 tags: + - 贪心 - 数组 - 二分查找 --- diff --git a/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README_EN.md b/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README_EN.md index b055c4f3665be..99292c4cf5670 100644 --- a/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README_EN.md +++ b/solution/2000-2099/2064.Minimized Maximum of Products Distributed to Any Store/README_EN.md @@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2000-2099/2064.Mi rating: 1885 source: Weekly Contest 266 Q3 tags: + - Greedy - Array - Binary Search --- diff --git a/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README.md b/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README.md index c75f416388f8a..875e6ab1f5882 100644 --- a/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README.md +++ b/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README.md @@ -62,7 +62,7 @@ tags:

    提示:

      -
    • 1 <= candies.length <= 105
    • +
    • 0 <= candies.length <= 105
    • 1 <= candies[i] <= 105
    • 0 <= k <= candies.length
    diff --git a/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README_EN.md b/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README_EN.md index 015b016e29833..05458581bfeab 100644 --- a/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README_EN.md +++ b/solution/2100-2199/2107.Number of Unique Flavors After Sharing K Candies/README_EN.md @@ -61,7 +61,7 @@ There are 3 unique flavors, so return 3.

    Constraints:

      -
    • 1 <= candies.length <= 105
    • +
    • 0 <= candies.length <= 105
    • 1 <= candies[i] <= 105
    • 0 <= k <= candies.length
    diff --git a/solution/2500-2599/2502.Design Memory Allocator/README.md b/solution/2500-2599/2502.Design Memory Allocator/README.md index c305de98775d2..dbfed0eb914ab 100644 --- a/solution/2500-2599/2502.Design Memory Allocator/README.md +++ b/solution/2500-2599/2502.Design Memory Allocator/README.md @@ -42,31 +42,32 @@ tags:
    • Allocator(int n) 使用一个大小为 n 的内存数组初始化 Allocator 对象。
    • int allocate(int size, int mID) 找出大小为 size 个连续空闲内存单元且位于  最左侧 的块,分配并赋 id mID 。返回块的第一个下标。如果不存在这样的块,返回 -1
    • -
    • int free(int mID) 释放 id mID 对应的所有内存单元。返回释放的内存单元数目。
    • +
    • int freeMemory(int mID) 释放 id mID 对应的所有内存单元。返回释放的内存单元数目。

     

    示例:

    -
    输入
    -["Allocator", "allocate", "allocate", "allocate", "free", "allocate", "allocate", "allocate", "free", "allocate", "free"]
    +
    +输入
    +["Allocator", "allocate", "allocate", "allocate", "freeMemory", "allocate", "allocate", "allocate", "freeMemory", "allocate", "freeMemory"]
     [[10], [1, 1], [1, 2], [1, 3], [2], [3, 4], [1, 1], [1, 1], [1], [10, 2], [7]]
     输出
     [null, 0, 1, 2, 1, 3, 1, 6, 3, -1, 0]
     
     解释
     Allocator loc = new Allocator(10); // 初始化一个大小为 10 的内存数组,所有内存单元都是空闲的。
    -loc.allocate(1, 1); // 最左侧的块的第一个下标是 0 。内存数组变为 [1, , , , , , , , , ]。返回 0 。
    -loc.allocate(1, 2); // 最左侧的块的第一个下标是 1 。内存数组变为 [1,2, , , , , , , , ]。返回 1 。
    -loc.allocate(1, 3); // 最左侧的块的第一个下标是 2 。内存数组变为 [1,2,3, , , , , , , ]。返回 2 。
    -loc.free(2); // 释放 mID 为 2 的所有内存单元。内存数组变为 [1, ,3, , , , , , , ] 。返回 1 ,因为只有 1 个 mID 为 2 的内存单元。
    -loc.allocate(3, 4); // 最左侧的块的第一个下标是 3 。内存数组变为 [1, ,3,4,4,4, , , , ]。返回 3 。
    -loc.allocate(1, 1); // 最左侧的块的第一个下标是 1 。内存数组变为 [1,1,3,4,4,4, , , , ]。返回 1 。
    -loc.allocate(1, 1); // 最左侧的块的第一个下标是 6 。内存数组变为 [1,1,3,4,4,4,1, , , ]。返回 6 。
    -loc.free(1); // 释放 mID 为 1 的所有内存单元。内存数组变为 [ , ,3,4,4,4, , , , ] 。返回 3 ,因为有 3 个 mID 为 1 的内存单元。
    +loc.allocate(1, 1); // 最左侧的块的第一个下标是 0 。内存数组变为 [1, , , , , , , , , ]。返回 0 。
    +loc.allocate(1, 2); // 最左侧的块的第一个下标是 1 。内存数组变为 [1,2, , , , , , , , ]。返回 1 。
    +loc.allocate(1, 3); // 最左侧的块的第一个下标是 2 。内存数组变为 [1,2,3, , , , , , , ]。返回 2 。
    +loc.freeMemory(2); // 释放 mID 为 2 的所有内存单元。内存数组变为 [1, ,3, , , , , , , ] 。返回 1 ,因为只有 1 个 mID 为 2 的内存单元。
    +loc.allocate(3, 4); // 最左侧的块的第一个下标是 3 。内存数组变为 [1, ,3,4,4,4, , , , ]。返回 3 。
    +loc.allocate(1, 1); // 最左侧的块的第一个下标是 1 。内存数组变为 [1,1,3,4,4,4, , , , ]。返回 1 。
    +loc.allocate(1, 1); // 最左侧的块的第一个下标是 6 。内存数组变为 [1,1,3,4,4,4,1, , , ]。返回 6 。
    +loc.freeMemory(1); // 释放 mID 为 1 的所有内存单元。内存数组变为 [ , ,3,4,4,4, , , , ] 。返回 3 ,因为有 3 个 mID 为 1 的内存单元。
     loc.allocate(10, 2); // 无法找出长度为 10 个连续空闲内存单元的空闲块,所有返回 -1 。
    -loc.free(7); // 释放 mID 为 7 的所有内存单元。内存数组保持原状,因为不存在 mID 为 7 的内存单元。返回 0 。
    +loc.freeMemory(7); // 释放 mID 为 7 的所有内存单元。内存数组保持原状,因为不存在 mID 为 7 的内存单元。返回 0 。
     

     

    diff --git a/solution/2500-2599/2532.Time to Cross a Bridge/README.md b/solution/2500-2599/2532.Time to Cross a Bridge/README.md index 13d8745f06838..bb40a5b144f6f 100644 --- a/solution/2500-2599/2532.Time to Cross a Bridge/README.md +++ b/solution/2500-2599/2532.Time to Cross a Bridge/README.md @@ -20,33 +20,33 @@ tags: -

    共有 k 位工人计划将 n 个箱子从旧仓库移动到新仓库。给你两个整数 nk,以及一个二维整数数组 time ,数组的大小为 k x 4 ,其中 time[i] = [leftToRighti, pickOldi, rightToLefti, putNewi]

    +

    共有 k 位工人计划将 n 个箱子从右侧的(旧)仓库移动到左侧的(新)仓库。给你两个整数 nk,以及一个二维整数数组 time ,数组的大小为 k x 4 ,其中 time[i] = [righti, picki, lefti, puti]

    一条河将两座仓库分隔,只能通过一座桥通行。旧仓库位于河的右岸,新仓库在河的左岸。开始时,所有 k 位工人都在桥的左侧等待。为了移动这些箱子,第 i 位工人(下标从 0 开始)可以:

      -
    • 从左岸(新仓库)跨过桥到右岸(旧仓库),用时 leftToRighti 分钟。
    • -
    • 从旧仓库选择一个箱子,并返回到桥边,用时 pickOldi 分钟。不同工人可以同时搬起所选的箱子。
    • -
    • 从右岸(旧仓库)跨过桥到左岸(新仓库),用时 rightToLefti 分钟。
    • -
    • 将箱子放入新仓库,并返回到桥边,用时 putNewi 分钟。不同工人可以同时放下所选的箱子。
    • +
    • 从左岸(新仓库)跨过桥到右岸(旧仓库),用时 righti 分钟。
    • +
    • 从旧仓库选择一个箱子,并返回到桥边,用时 picki 分钟。不同工人可以同时搬起所选的箱子。
    • +
    • 从右岸(旧仓库)跨过桥到左岸(新仓库),用时 lefti 分钟。
    • +
    • 将箱子放入新仓库,并返回到桥边,用时 puti 分钟。不同工人可以同时放下所选的箱子。

    如果满足下面任一条件,则认为工人 i效率低于 工人 j

      -
    • leftToRighti + rightToLefti > leftToRightj + rightToLeftj
    • -
    • leftToRighti + rightToLefti == leftToRightj + rightToLeftji > j
    • +
    • lefti + righti > leftj + rightj
    • +
    • lefti + righti == leftj + rightji > j

    工人通过桥时需要遵循以下规则:

      -
    • 如果工人 x 到达桥边时,工人 y 正在过桥,那么工人 x 需要在桥边等待。
    • +
    • 同时只能有一名工人过桥。
    • 当桥梁未被使用时,优先让右侧 效率最低 的工人(已经拿起盒子的工人)过桥。如果不是,优先让左侧 效率最低 的工人通过。
    • 如果左侧已经派出足够的工人来拾取所有剩余的箱子,则 不会 再从左侧派出工人。
    -

    所有 n 个盒子都需要放入新仓库,请你返回最后一个搬运箱子的工人 到达河左岸 的时间。

    +

    请你返回最后一个箱子 到达桥左侧 的时间。

     

    @@ -92,7 +92,7 @@ tags:
  • 1 <= n, k <= 104
  • time.length == k
  • time[i].length == 4
  • -
  • 1 <= leftToRighti, pickOldi, rightToLefti, putNewi <= 1000
  • +
  • 1 <= lefti, picki, righti, puti <= 1000
  • diff --git a/solution/2500-2599/2537.Count the Number of Good Subarrays/README_EN.md b/solution/2500-2599/2537.Count the Number of Good Subarrays/README_EN.md index 441d921c2108b..16f4e856b5de9 100644 --- a/solution/2500-2599/2537.Count the Number of Good Subarrays/README_EN.md +++ b/solution/2500-2599/2537.Count the Number of Good Subarrays/README_EN.md @@ -22,7 +22,7 @@ tags:

    Given an integer array nums and an integer k, return the number of good subarrays of nums.

    -

    A subarray arr is good if it there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j].

    +

    A subarray arr is good if there are at least k pairs of indices (i, j) such that i < j and arr[i] == arr[j].

    A subarray is a contiguous non-empty sequence of elements within an array.

    diff --git a/solution/2500-2599/2577.Minimum Time to Visit a Cell In a Grid/README_EN.md b/solution/2500-2599/2577.Minimum Time to Visit a Cell In a Grid/README_EN.md index 4da803f6954cf..3c88d6c8193cf 100644 --- a/solution/2500-2599/2577.Minimum Time to Visit a Cell In a Grid/README_EN.md +++ b/solution/2500-2599/2577.Minimum Time to Visit a Cell In a Grid/README_EN.md @@ -72,7 +72,7 @@ The final time is 7. It can be shown that it is the minimum time possible.

     

    -