diff --git a/solution/2800-2899/2869.Minimum Operations to Collect Elements/README.md b/solution/2800-2899/2869.Minimum Operations to Collect Elements/README.md index 5989f13b3c5de..863ecfa6bbe16 100644 --- a/solution/2800-2899/2869.Minimum Operations to Collect Elements/README.md +++ b/solution/2800-2899/2869.Minimum Operations to Collect Elements/README.md @@ -1,4 +1,4 @@ -# [2869. Minimum Operations to Collect Elements](https://leetcode.cn/problems/minimum-operations-to-collect-elements/) +# [2869. 收集元素的最少操作次数](https://leetcode.cn/problems/minimum-operations-to-collect-elements/) [English Version](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README_EN.md) @@ -6,6 +6,8 @@ +

给你一个正整数数组 nums 和一个整数 k 。

+

一次操作中,你可以将数组的最后一个元素删除,将该元素添加到一个集合中。

请你返回收集元素 1, 2, ..., k 需要的 最少操作次数 。

@@ -14,21 +16,24 @@

示例 1:

-
输入:nums = [3,1,5,4,2], k = 2
+
+输入:nums = [3,1,5,4,2], k = 2
 输出:4
 解释:4 次操作后,集合中的元素依次添加了 2 ,4 ,5 和 1 。此时集合中包含元素 1 和 2 ,所以答案为 4 。
 

示例 2:

-
输入:nums = [3,1,5,4,2], k = 5
+
+输入:nums = [3,1,5,4,2], k = 5
 输出:5
 解释:5 次操作后,集合中的元素依次添加了 2 ,4 ,5 ,1 和 3 。此时集合中包含元素 1 到 5 ,所以答案为 5 。
 

示例 3:

-
输入:nums = [3,2,5,3,1], k = 3
+
+输入:nums = [3,2,5,3,1], k = 3
 输出:4
 解释:4 次操作后,集合中的元素依次添加了 1 ,3 ,5 和 2 。此时集合中包含元素 1 到 3  ,所以答案为 4 。
 
diff --git a/solution/2800-2899/2869.Minimum Operations to Collect Elements/README_EN.md b/solution/2800-2899/2869.Minimum Operations to Collect Elements/README_EN.md index beb63278bcdb3..659952c71030c 100644 --- a/solution/2800-2899/2869.Minimum Operations to Collect Elements/README_EN.md +++ b/solution/2800-2899/2869.Minimum Operations to Collect Elements/README_EN.md @@ -4,6 +4,8 @@ ## Description +

You are given an array nums of positive integers and an integer k.

+

In one operation, you can remove the last element of the array and add it to your collection.

Return the minimum number of operations needed to collect elements 1, 2, ..., k.

@@ -11,21 +13,24 @@

 

Example 1:

-
Input: nums = [3,1,5,4,2], k = 2
+
+Input: nums = [3,1,5,4,2], k = 2
 Output: 4
 Explanation: After 4 operations, we collect elements 2, 4, 5, and 1, in this order. Our collection contains elements 1 and 2. Hence, the answer is 4.
 

Example 2:

-
Input: nums = [3,1,5,4,2], k = 5
+
+Input: nums = [3,1,5,4,2], k = 5
 Output: 5
 Explanation: After 5 operations, we collect elements 2, 4, 5, 1, and 3, in this order. Our collection contains elements 1 through 5. Hence, the answer is 5.
 

Example 3:

-
Input: nums = [3,2,5,3,1], k = 3
+
+Input: nums = [3,2,5,3,1], k = 3
 Output: 4
 Explanation: After 4 operations, we collect elements 1, 3, 5, and 2, in this order. Our collection contains elements 1 through 3. Hence, the answer is 4.
 
diff --git a/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README.md b/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README.md index a6ffda2bf7b15..3c9942aef5e2b 100644 --- a/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README.md +++ b/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README.md @@ -1,4 +1,4 @@ -# [2870. Minimum Number of Operations to Make Array Empty](https://leetcode.cn/problems/minimum-number-of-operations-to-make-array-empty/) +# [2870. 使数组为空的最少操作次数](https://leetcode.cn/problems/minimum-number-of-operations-to-make-array-empty/) [English Version](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README_EN.md) @@ -6,6 +6,8 @@ +

给你一个下标从 0 开始的正整数数组 nums 。

+

你可以对数组执行以下两种操作 任意次 :

    @@ -19,7 +21,8 @@

    示例 1:

    -
    输入:nums = [2,3,3,2,2,4,2,3,4]
    +
    +输入:nums = [2,3,3,2,2,4,2,3,4]
     输出:4
     解释:我们可以执行以下操作使数组为空:
     - 对下标为 0 和 3 的元素执行第一种操作,得到 nums = [3,3,2,4,2,3,4] 。
    @@ -31,7 +34,8 @@
     
     

    示例 2:

    -
    输入:nums = [2,1,2,2,3,3]
    +
    +输入:nums = [2,1,2,2,3,3]
     输出:-1
     解释:无法使数组为空。
     
    diff --git a/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README_EN.md b/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README_EN.md index f1e4f0c13fc85..8a4b7ca90ed6e 100644 --- a/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README_EN.md +++ b/solution/2800-2899/2870.Minimum Number of Operations to Make Array Empty/README_EN.md @@ -4,6 +4,8 @@ ## Description +

    You are given a 0-indexed array nums consisting of positive integers.

    +

    There are two types of operations that you can apply on the array any number of times:

      @@ -16,7 +18,8 @@

       

      Example 1:

      -
      Input: nums = [2,3,3,2,2,4,2,3,4]
      +
      +Input: nums = [2,3,3,2,2,4,2,3,4]
       Output: 4
       Explanation: We can apply the following operations to make the array empty:
       - Apply the first operation on the elements at indices 0 and 3. The resulting array is nums = [3,3,2,4,2,3,4].
      @@ -28,7 +31,8 @@ It can be shown that we cannot make the array empty in less than 4 operations.
       
       

      Example 2:

      -
      Input: nums = [2,1,2,2,3,3]
      +
      +Input: nums = [2,1,2,2,3,3]
       Output: -1
       Explanation: It is impossible to empty the array.
       
      diff --git a/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README.md b/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README.md index 34a6162d75242..a12a5f4d18eda 100644 --- a/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README.md +++ b/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README.md @@ -1,4 +1,4 @@ -# [2871. Split Array Into Maximum Number of Subarrays](https://leetcode.cn/problems/split-array-into-maximum-number-of-subarrays/) +# [2871. 将数组分割成最多数目的子数组](https://leetcode.cn/problems/split-array-into-maximum-number-of-subarrays/) [English Version](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README_EN.md) @@ -6,6 +6,8 @@ +

      给你一个只包含 非负 整数的数组 nums 。

      +

      我们定义满足 l <= r 的子数组 nums[l..r] 的分数为 nums[l] AND nums[l + 1] AND ... AND nums[r] ,其中 AND 是按位与运算。

      请你将数组分割成一个或者更多子数组,满足:

      @@ -23,7 +25,8 @@

      示例 1:

      -
      输入:nums = [1,0,2,0,1,2]
      +
      +输入:nums = [1,0,2,0,1,2]
       输出:3
       解释:我们可以将数组分割成以下子数组:
       - [1,0] 。子数组分数为 1 AND 0 = 0 。
      @@ -35,7 +38,8 @@
       
       

      示例 2:

      -
      输入:nums = [5,7,1,3]
      +
      +输入:nums = [5,7,1,3]
       输出:1
       解释:我们可以将数组分割成一个子数组:[5,7,1,3] ,分数为 1 ,这是可以得到的最小总分数。
       在总分数为 1 的前提下,最多可以将数组分割成 1 个子数组。所以返回 1 。
      diff --git a/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README_EN.md b/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README_EN.md
      index bb225e009d802..c75a8ffac55ba 100644
      --- a/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README_EN.md	
      +++ b/solution/2800-2899/2871.Split Array Into Maximum Number of Subarrays/README_EN.md	
      @@ -4,6 +4,8 @@
       
       ## Description
       
      +

      You are given an array nums consisting of non-negative integers.

      +

      We define the score of subarray nums[l..r] such that l <= r as nums[l] AND nums[l + 1] AND ... AND nums[r] where AND is the bitwise AND operation.

      Consider splitting the array into one or more subarrays such that the following conditions are satisfied:

      @@ -20,7 +22,8 @@

       

      Example 1:

      -
      Input: nums = [1,0,2,0,1,2]
      +
      +Input: nums = [1,0,2,0,1,2]
       Output: 3
       Explanation: We can split the array into the following subarrays:
       - [1,0]. The score of this subarray is 1 AND 0 = 0.
      @@ -32,7 +35,8 @@ It can be shown that we cannot split the array into more than 3 subarrays with a
       
       

      Example 2:

      -
      Input: nums = [5,7,1,3]
      +
      +Input: nums = [5,7,1,3]
       Output: 1
       Explanation: We can split the array into one subarray: [5,7,1,3] with a score of 1, which is the minimum possible score that we can obtain.
       It can be shown that we cannot split the array into more than 1 subarray with a total score of 1. So we return 1.
      diff --git a/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README.md b/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README.md
      index c49e4de881819..91dfdcd6a9d11 100644
      --- a/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README.md	
      +++ b/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README.md	
      @@ -1,4 +1,4 @@
      -# [2872. Maximum Number of K-Divisible Components](https://leetcode.com/problems/maximum-number-of-k-divisible-components/)
      +# [2872. 可以被 K 整除连通块的最大数目](https://leetcode.com/problems/maximum-number-of-k-divisible-components/)
       
       [English Version](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md)
       
      @@ -18,9 +18,10 @@
       
       

      示例 1:

      -

      +

      -
      输入:n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
      +
      +输入:n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
       输出:2
       解释:我们删除节点 1 和 2 之间的边。这是一个合法分割,因为:
       - 节点 1 和 3 所在连通块的值为 values[1] + values[3] = 12 。
      @@ -29,9 +30,10 @@
       
       

      示例 2:

      -

      +

      -
      输入:n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
      +
      +输入:n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
       输出:3
       解释:我们删除节点 0 和 2 ,以及节点 0 和 1 之间的边。这是一个合法分割,因为:
       - 节点 0 的连通块的值为 values[0] = 3 。
      diff --git a/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README_EN.md b/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README_EN.md
      index 65b50f2aa42ff..0b502b8f8a566 100644
      --- a/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README_EN.md	
      +++ b/solution/2800-2899/2872.Maximum Number of K-Divisible Components/README_EN.md	
      @@ -14,8 +14,9 @@
       
       

       

      Example 1:

      - -
      Input: n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
      +
      +
      +Input: n = 5, edges = [[0,2],[1,2],[1,3],[2,4]], values = [1,8,1,4,4], k = 6
       Output: 2
       Explanation: We remove the edge connecting node 1 with 2. The resulting split is valid because:
       - The value of the component containing nodes 1 and 3 is values[1] + values[3] = 12.
      @@ -23,8 +24,9 @@
       It can be shown that no other valid split has more than 2 connected components.

      Example 2:

      - -
      Input: n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
      +
      +
      +Input: n = 7, edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]], values = [3,0,6,1,5,2,1], k = 3
       Output: 3
       Explanation: We remove the edge connecting node 0 with 2, and the edge connecting node 0 with 1. The resulting split is valid because:
       - The value of the component containing node 0 is values[0] = 3.
      diff --git a/solution/CONTEST_README.md b/solution/CONTEST_README.md
      index 112de2f1ed4b8..e208b759bee2a 100644
      --- a/solution/CONTEST_README.md
      +++ b/solution/CONTEST_README.md
      @@ -22,6 +22,13 @@
       
       ## 往期竞赛
       
      +#### 第 114 场双周赛(2023-09-30 22:30, 90 分钟) 参赛人数 2406
      +
      +- [2869. 收集元素的最少操作次数](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README.md)
      +- [2870. 使数组为空的最少操作次数](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README.md)
      +- [2871. 将数组分割成最多数目的子数组](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README.md)
      +- [2872. 可以被 K 整除连通块的最大数目](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README.md)
      +
       #### 第 364 场周赛(2023-09-24 10:30, 90 分钟) 参赛人数 4304
       
       - [2864. 最大二进制奇数](/solution/2800-2899/2864.Maximum%20Odd%20Binary%20Number/README.md)
      diff --git a/solution/CONTEST_README_EN.md b/solution/CONTEST_README_EN.md
      index ac78a39463c6b..402e1c5a0b276 100644
      --- a/solution/CONTEST_README_EN.md
      +++ b/solution/CONTEST_README_EN.md
      @@ -25,6 +25,13 @@ Get your rating changes right after the completion of LeetCode contests, https:/
       
       ## Past Contests
       
      +#### Biweekly Contest 114
      +
      +- [2869. Minimum Operations to Collect Elements](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README_EN.md)
      +- [2870. Minimum Number of Operations to Make Array Empty](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README_EN.md)
      +- [2871. Split Array Into Maximum Number of Subarrays](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README_EN.md)
      +- [2872. Maximum Number of K-Divisible Components](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md)
      +
       #### Weekly Contest 364
       
       - [2864. Maximum Odd Binary Number](/solution/2800-2899/2864.Maximum%20Odd%20Binary%20Number/README_EN.md)
      diff --git a/solution/README.md b/solution/README.md
      index d588236234918..b4c6c94613db6 100644
      --- a/solution/README.md
      +++ b/solution/README.md
      @@ -2879,6 +2879,10 @@
       |  2866  |  [美丽塔 II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README.md)  |  `栈`,`数组`,`单调栈`  |  中等  |  第 364 场周赛  |
       |  2867  |  [统计树中的合法路径数目](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README.md)  |  `树`,`深度优先搜索`,`数学`,`动态规划`,`数论`  |  困难  |  第 364 场周赛  |
       |  2868  |  [单词游戏](/solution/2800-2899/2868.The%20Wording%20Game/README.md)  |    |  困难  |  🔒  |
      +|  2869  |  [收集元素的最少操作次数](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README.md)  |    |  简单  |  第 114 场双周赛  |
      +|  2870  |  [使数组为空的最少操作次数](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README.md)  |    |  中等  |  第 114 场双周赛  |
      +|  2871  |  [将数组分割成最多数目的子数组](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README.md)  |    |  中等  |  第 114 场双周赛  |
      +|  2872  |  [可以被 K 整除连通块的最大数目](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README.md)  |    |  困难  |  第 114 场双周赛  |
       
       ## 版权
       
      diff --git a/solution/README_EN.md b/solution/README_EN.md
      index bf63c7be8fa55..063d6d0b80e28 100644
      --- a/solution/README_EN.md
      +++ b/solution/README_EN.md
      @@ -2877,6 +2877,10 @@ Press Control + F(or Command + F on
       |  2866  |  [Beautiful Towers II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README_EN.md)  |  `Stack`,`Array`,`Monotonic Stack`  |  Medium  |  Weekly Contest 364  |
       |  2867  |  [Count Valid Paths in a Tree](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README_EN.md)  |  `Tree`,`Depth-First Search`,`Math`,`Dynamic Programming`,`Number Theory`  |  Hard  |  Weekly Contest 364  |
       |  2868  |  [The Wording Game](/solution/2800-2899/2868.The%20Wording%20Game/README_EN.md)  |    |  Hard  |  🔒  |
      +|  2869  |  [Minimum Operations to Collect Elements](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README_EN.md)  |    |  Easy  |  Biweekly Contest 114  |
      +|  2870  |  [Minimum Number of Operations to Make Array Empty](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README_EN.md)  |    |  Medium  |  Biweekly Contest 114  |
      +|  2871  |  [Split Array Into Maximum Number of Subarrays](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README_EN.md)  |    |  Medium  |  Biweekly Contest 114  |
      +|  2872  |  [Maximum Number of K-Divisible Components](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md)  |    |  Hard  |  Biweekly Contest 114  |
       
       ## Copyright
       
      diff --git a/solution/summary.md b/solution/summary.md
      index de6e3c4339afa..db413d03a6e9c 100644
      --- a/solution/summary.md
      +++ b/solution/summary.md
      @@ -2924,3 +2924,7 @@
         - [2866.美丽塔 II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README.md)
         - [2867.统计树中的合法路径数目](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README.md)
         - [2868.单词游戏](/solution/2800-2899/2868.The%20Wording%20Game/README.md)
      +  - [2869.收集元素的最少操作次数](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README.md)
      +  - [2870.使数组为空的最少操作次数](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README.md)
      +  - [2871.将数组分割成最多数目的子数组](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README.md)
      +  - [2872.可以被 K 整除连通块的最大数目](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README.md)
      diff --git a/solution/summary_en.md b/solution/summary_en.md
      index 87ac5434ac6f0..f93c810958946 100644
      --- a/solution/summary_en.md
      +++ b/solution/summary_en.md
      @@ -2924,3 +2924,7 @@
         - [2866.Beautiful Towers II](/solution/2800-2899/2866.Beautiful%20Towers%20II/README_EN.md)
         - [2867.Count Valid Paths in a Tree](/solution/2800-2899/2867.Count%20Valid%20Paths%20in%20a%20Tree/README_EN.md)
         - [2868.The Wording Game](/solution/2800-2899/2868.The%20Wording%20Game/README_EN.md)
      +  - [2869.Minimum Operations to Collect Elements](/solution/2800-2899/2869.Minimum%20Operations%20to%20Collect%20Elements/README_EN.md)
      +  - [2870.Minimum Number of Operations to Make Array Empty](/solution/2800-2899/2870.Minimum%20Number%20of%20Operations%20to%20Make%20Array%20Empty/README_EN.md)
      +  - [2871.Split Array Into Maximum Number of Subarrays](/solution/2800-2899/2871.Split%20Array%20Into%20Maximum%20Number%20of%20Subarrays/README_EN.md)
      +  - [2872.Maximum Number of K-Divisible Components](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md)