diff --git a/solution/0400-0499/0480.Sliding Window Median/README_EN.md b/solution/0400-0499/0480.Sliding Window Median/README_EN.md index e1e9384fd8a51..7dcbf3e826a65 100644 --- a/solution/0400-0499/0480.Sliding Window Median/README_EN.md +++ b/solution/0400-0499/0480.Sliding Window Median/README_EN.md @@ -36,7 +36,7 @@ tags:
Input: nums = [1,3,-1,-3,5,3,6,7], k = 3 Output: [1.00000,-1.00000,-1.00000,3.00000,5.00000,6.00000] -Explanation: +Explanation: Window position Median --------------- ----- [1 3 -1] -3 5 3 6 7 1 diff --git a/solution/0500-0599/0588.Design In-Memory File System/README.md b/solution/0500-0599/0588.Design In-Memory File System/README.md index b543fc76a3ce8..357f38fcca065 100644 --- a/solution/0500-0599/0588.Design In-Memory File System/README.md +++ b/solution/0500-0599/0588.Design In-Memory File System/README.md @@ -77,6 +77,7 @@ fileSystem.readContentFromFile("/a/b/c/d"); // 返回 "hello"
path
和 filePath
都是绝对路径,除非是根目录 ‘/’
自身,其他路径都是以 ‘/’
开头且 不 以 ‘/’
结束。addContentToFile
中的文件的父目录都存在。1 <= content.length <= 50
ls
, mkdir
, addContentToFile
, and readContentFromFile
最多被调用 300
次如果对 words2
中的每一个单词 b
,b
都是 a
的子集,那么我们称 words1
中的单词 a
是 通用单词 。
以数组形式返回 words1
中所有的通用单词。你可以按 任意顺序 返回答案。
以数组形式返回 words1
中所有的 通用 单词。你可以按 任意顺序 返回答案。
示例 1:
+示例 1:
--输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"] -输出:["facebook","google","leetcode"] -+
输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","o"]
-示例 2:
+输出:["facebook","google","leetcode"]
+-输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["l","e"] -输出:["apple","google","leetcode"] -+
示例 2:
-示例 3:
+输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lc","eo"]
--输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["e","oo"] -输出:["facebook","google"] -+
输出:["leetcode"]
+示例 4:
+示例 3:
--输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["lo","eo"] -输出:["google","leetcode"] -+
输入:words1 = ["acaac","cccbb","aacbb","caacc","bcbbb"], words2 = ["c","cc","b"]
-示例 5:
- --输入:words1 = ["amazon","apple","facebook","google","leetcode"], words2 = ["ec","oc","ceo"] -输出:["facebook","leetcode"] -+
输出:["cccbb"]
+diff --git a/solution/0900-0999/0975.Odd Even Jump/README_EN.md b/solution/0900-0999/0975.Odd Even Jump/README_EN.md index f3d8f0f75c976..99f76a4a016e2 100644 --- a/solution/0900-0999/0975.Odd Even Jump/README_EN.md +++ b/solution/0900-0999/0975.Odd Even Jump/README_EN.md @@ -40,7 +40,7 @@ tags:
Input: arr = [10,13,12,14,15] Output: 2 -Explanation: +Explanation: From starting index i = 0, we can make our 1st jump to i = 2 (since arr[2] is the smallest among arr[1], arr[2], arr[3], arr[4] that is greater or equal to arr[0]), then we cannot jump any more. From starting index i = 1 and i = 2, we can make our 1st jump to i = 3, then we cannot jump any more. From starting index i = 3, we can make our 1st jump to i = 4, so we have reached the end. @@ -54,7 +54,7 @@ jumps.diff --git a/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md b/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md index 83dbe80cffbf8..d3cf52c0d5cfe 100644 --- a/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md +++ b/solution/1300-1399/1348.Tweet Counts Per Frequency/README.md @@ -68,7 +68,7 @@ tweetCounts.recordTweet("tweet3", 0); tweetCounts.recordTweet("tweet3", 60); tweetCounts.recordTweet("tweet3", 10); // "tweet3" 发布推文的时间分别是 0, 10 和 60 。 tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 59); // 返回 [2]。统计频率是每分钟(60 秒),因此只有一个有效时间间隔 [0,60> - > 2 条推文。 -tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // 返回 [2,1]。统计频率是每分钟(60 秒),因此有两个有效时间间隔 1) [0,60> - > 2 条推文,和 2) [60,61> - > 1 条推文。 +tweetCounts.getTweetCountsPerFrequency("minute", "tweet3", 0, 60); // 返回 [2,1]。统计频率是每分钟(60 秒),因此有两个有效时间间隔 1) [0,60> - > 2 条推文,和 2) [60,61> - > 1 条推文。 tweetCounts.recordTweet("tweet3", 120); // "tweet3" 发布推文的时间分别是 0, 10, 60 和 120 。 tweetCounts.getTweetCountsPerFrequency("hour", "tweet3", 0, 210); // 返回 [4]。统计频率是每小时(3600 秒),因此只有一个有效时间间隔 [0,211> - > 4 条推文。 diff --git a/solution/1400-1499/1400.Construct K Palindrome Strings/README.md b/solution/1400-1499/1400.Construct K Palindrome Strings/README.md index b8ec712c5656a..fe8d098302ddd 100644 --- a/solution/1400-1499/1400.Construct K Palindrome Strings/README.md +++ b/solution/1400-1499/1400.Construct K Palindrome Strings/README.md @@ -21,7 +21,7 @@ tags: -Input: arr = [2,3,1,1,4] Output: 3 -Explanation: +Explanation: From starting index i = 0, we make jumps to i = 1, i = 2, i = 3: During our 1st jump (odd-numbered), we first jump to i = 1 because arr[1] is the smallest value in [arr[1], arr[2], arr[3], arr[4]] that is greater than or equal to arr[0]. During our 2nd jump (even-numbered), we jump from i = 1 to i = 2 because arr[2] is the largest value in [arr[2], arr[3], arr[4]] that is less than or equal to arr[1]. arr[3] is also the largest value, but 2 is a smaller index, so we can only jump to i = 2 and not i = 3 diff --git a/solution/1100-1199/1172.Dinner Plate Stacks/README.md b/solution/1100-1199/1172.Dinner Plate Stacks/README.md index ced8ea8849c43..dcc64da0f7884 100644 --- a/solution/1100-1199/1172.Dinner Plate Stacks/README.md +++ b/solution/1100-1199/1172.Dinner Plate Stacks/README.md @@ -65,14 +65,14 @@ D.popAtStack(0); // 返回 20。栈的现状为: 4 21 ﹈ ﹈ ﹈ D.popAtStack(2); // 返回 21。栈的现状为: 4 1 3 5 - ﹈ ﹈ ﹈ + ﹈ ﹈ ﹈ D.pop() // 返回 5。栈的现状为: 4 - 1 3 - ﹈ ﹈ -D.pop() // 返回 4。栈的现状为: 1 3 - ﹈ ﹈ -D.pop() // 返回 3。栈的现状为: 1 - ﹈ + 1 3 + ﹈ ﹈ +D.pop() // 返回 4。栈的现状为: 1 3 + ﹈ ﹈ +D.pop() // 返回 3。栈的现状为: 1 + ﹈ D.pop() // 返回 1。现在没有栈。 D.pop() // 返回 -1。仍然没有栈。diff --git a/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md b/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md index a1b5f39c39692..7f1837953bb7a 100644 --- a/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md +++ b/solution/1100-1199/1172.Dinner Plate Stacks/README_EN.md @@ -42,7 +42,7 @@ tags: Output [null, null, null, null, null, null, 2, null, null, 20, 21, 5, 4, 3, 1, -1] -Explanation: +Explanation: DinnerPlates D = DinnerPlates(2); // Initialize with capacity = 2 D.push(1); D.push(2); @@ -65,14 +65,14 @@ D.popAtStack(0); // Returns 20. The stacks are now: 4 21 ﹈ ﹈ ﹈ D.popAtStack(2); // Returns 21. The stacks are now: 4 1 3 5 - ﹈ ﹈ ﹈ + ﹈ ﹈ ﹈ D.pop() // Returns 5. The stacks are now: 4 - 1 3 - ﹈ ﹈ -D.pop() // Returns 4. The stacks are now: 1 3 - ﹈ ﹈ -D.pop() // Returns 3. The stacks are now: 1 - ﹈ + 1 3 + ﹈ ﹈ +D.pop() // Returns 4. The stacks are now: 1 3 + ﹈ ﹈ +D.pop() // Returns 3. The stacks are now: 1 + ﹈ D.pop() // Returns 1. There are no stacks. D.pop() // Returns -1. There are still no stacks.
给你一个字符串 s
和一个整数 k
。请你用 s
字符串中 所有字符 构造 k
个非空 回文串 。
给你一个字符串 s
和一个整数 k
。请你用 s
字符串中 所有字符 构造 k
个非空 回文串 。
如果你可以用 s
中所有字符构造 k
个回文字符串,那么请你返回 True ,否则返回 False 。
示例 1:
-输入:s = "annabelle", k = 2 +输入:s = "annabelle", k = 2 输出:true 解释:可以用 s 中所有字符构造 2 个回文字符串。 -一些可行的构造方案包括:"anna" + "elble","anbna" + "elle","anellena" + "b" +一些可行的构造方案包括:"anna" + "elble","anbna" + "elle","anellena" + "b"
示例 2:
-输入:s = "leetcode", k = 3 +输入:s = "leetcode", k = 3 输出:false 解释:无法用 s 中所有字符构造 3 个回文串。@@ -47,35 +47,19 @@ tags:
示例 3:
-输入:s = "true", k = 4 +输入:s = "true", k = 4 输出:true 解释:唯一可行的方案是让 s 中每个字符单独构成一个字符串。-
示例 4:
- --输入:s = "yzyzyzyzyzyzyzy", k = 2 -输出:true -解释:你只需要将所有的 z 放在一个字符串中,所有的 y 放在另一个字符串中。那么两个字符串都是回文串。 -- -
示例 5:
- --输入:s = "cr", k = 7 -输出:false -解释:我们没有足够的字符去构造 7 个回文串。 --
提示:
1 <= s.length <= 10^5
1 <= s.length <= 105
s
中所有字符都是小写英文字母。1 <= k <= 10^5
1 <= k <= 105
示例 1:
输入:nums = [8,2,4,7], limit = 4 -输出:2 +输出:2 解释:所有子数组如下: [8] 最大绝对差 |8-8| = 0 <= 4. -[8,2] 最大绝对差 |8-2| = 6 > 4. +[8,2] 最大绝对差 |8-2| = 6 > 4. [8,2,4] 最大绝对差 |8-2| = 6 > 4. [8,2,4,7] 最大绝对差 |8-2| = 6 > 4. [2] 最大绝对差 |2-2| = 0 <= 4. @@ -43,14 +43,14 @@ tags: [2,4,7] 最大绝对差 |2-7| = 5 > 4. [4] 最大绝对差 |4-4| = 0 <= 4. [4,7] 最大绝对差 |4-7| = 3 <= 4. -[7] 最大绝对差 |7-7| = 0 <= 4. +[7] 最大绝对差 |7-7| = 0 <= 4. 因此,满足题意的最长子数组的长度为 2 。
示例 2:
输入:nums = [10,1,2,4,7,2], limit = 5 -输出:4 +输出:4 解释:满足题意的最长子数组是 [2,4,7,2],其最大绝对差 |2-7| = 5 <= 5 。diff --git a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md index 07f167125aab5..838e7dae2e4b2 100644 --- a/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md +++ b/solution/1400-1499/1438.Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit/README_EN.md @@ -30,10 +30,10 @@ tags:
Input: nums = [8,2,4,7], limit = 4 -Output: 2 -Explanation: All subarrays are: +Output: 2 +Explanation: All subarrays are: [8] with maximum absolute diff |8-8| = 0 <= 4. -[8,2] with maximum absolute diff |8-2| = 6 > 4. +[8,2] with maximum absolute diff |8-2| = 6 > 4. [8,2,4] with maximum absolute diff |8-2| = 6 > 4. [8,2,4,7] with maximum absolute diff |8-2| = 6 > 4. [2] with maximum absolute diff |2-2| = 0 <= 4. @@ -41,7 +41,7 @@ tags: [2,4,7] with maximum absolute diff |2-7| = 5 > 4. [4] with maximum absolute diff |4-4| = 0 <= 4. [4,7] with maximum absolute diff |4-7| = 3 <= 4. -[7] with maximum absolute diff |7-7| = 0 <= 4. +[7] with maximum absolute diff |7-7| = 0 <= 4. Therefore, the size of the longest subarray is 2.@@ -49,7 +49,7 @@ Therefore, the size of the longest subarray is 2.
Input: nums = [10,1,2,4,7,2], limit = 5 -Output: 4 +Output: 4 Explanation: The subarray [2,4,7,2] is the longest since the maximum absolute diff is |2-7| = 5 <= 5.diff --git a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md index 8c534cf5a9efe..a78b2580463c1 100644 --- a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md +++ b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README.md @@ -41,8 +41,8 @@ tags:
-输入:k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] -输出:[1] +输入:k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] +输出:[1] 解释: 所有服务器一开始都是空闲的。 前 3 个请求分别由前 3 台服务器依次处理。 diff --git a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md index 6c8ae0631143e..11f80e8f7c508 100644 --- a/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md +++ b/solution/1600-1699/1606.Find Servers That Handled Most Number of Requests/README_EN.md @@ -38,9 +38,9 @@ tags:diff --git a/solution/2700-2799/2762.Continuous Subarrays/README_EN.md b/solution/2700-2799/2762.Continuous Subarrays/README_EN.md index 258846bd742cb..0b3ca5f943041 100644 --- a/solution/2700-2799/2762.Continuous Subarrays/README_EN.md +++ b/solution/2700-2799/2762.Continuous Subarrays/README_EN.md @@ -39,7 +39,7 @@ tags:Example 1:
-Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] -Output: [1] -Explanation: +Input: k = 3, arrival = [1,2,3,4,5], load = [5,2,3,3,3] +Output: [1] +Explanation: All of the servers start out available. The first 3 requests are handled by the first 3 servers in order. Request 3 comes in. Server 0 is busy, so it's assigned to the next available server, which is 1. @@ -53,7 +53,7 @@ Servers 0 and 2 handled one request each, while server 1 handled two requests. Hdiff --git a/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md b/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md index 0de9ec290eff7..0ff195c6f0e26 100644 --- a/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md +++ b/solution/2600-2699/2653.Sliding Subarray Beauty/README_EN.md @@ -38,7 +38,7 @@ tags:Input: k = 3, arrival = [1,2,3,4], load = [1,2,1,2] Output: [0] -Explanation: +Explanation: The first 3 requests are handled by first 3 servers. Request 3 comes in. It is handled by server 0 since the server is available. Server 0 handled two requests, while servers 1 and 2 handled one request each. Hence server 0 is the busiest server. diff --git a/solution/1800-1899/1825.Finding MK Average/README.md b/solution/1800-1899/1825.Finding MK Average/README.md index f7b67495227d5..fa970e64153d0 100644 --- a/solution/1800-1899/1825.Finding MK Average/README.md +++ b/solution/1800-1899/1825.Finding MK Average/README.md @@ -52,7 +52,7 @@ tags: [null, null, null, -1, null, 3, null, null, null, 5] 解释: -MKAverage obj = new MKAverage(3, 1); +MKAverage obj = new MKAverage(3, 1); obj.addElement(3); // 当前元素为 [3] obj.addElement(1); // 当前元素为 [3,1] obj.calculateMKAverage(); // 返回 -1 ,因为 m = 3 ,但数据流中只有 2 个元素 diff --git a/solution/1800-1899/1825.Finding MK Average/README_EN.md b/solution/1800-1899/1825.Finding MK Average/README_EN.md index 12b3147398684..47e210d29904b 100644 --- a/solution/1800-1899/1825.Finding MK Average/README_EN.md +++ b/solution/1800-1899/1825.Finding MK Average/README_EN.md @@ -51,7 +51,7 @@ tags: [null, null, null, -1, null, 3, null, null, null, 5] Explanation -diff --git a/solution/2500-2599/2590.Design a Todo List/README.md b/solution/2500-2599/2590.Design a Todo List/README.md index c66941f981134..8a3a3cb1e1ff0 100644 --- a/solution/2500-2599/2590.Design a Todo List/README.md +++ b/solution/2500-2599/2590.Design a Todo List/README.md @@ -44,17 +44,17 @@ tags: [null, 1, 2, ["Task1", "Task2"], [], 3, ["Task3", "Task2"], null, null, ["Task3"], ["Task3", "Task1"]] 解释 -TodoList todoList = new TodoList(); -todoList.addTask(1, "Task1", 50, []); // 返回1。为ID为1的用户添加一个新任务。 -todoList.addTask(1, "Task2", 100, ["P1"]); // 返回2。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 -todoList.getAllTasks(1); // 返回["Task1", "Task2"]。用户1目前有两个未完成的任务。 -todoList.getAllTasks(5); // 返回[]。用户5目前没有任务。 -todoList.addTask(1, "Task3", 30, ["P1"]); // 返回3。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 -todoList.getTasksForTag(1, "P1"); // 返回["Task3", "Task2"]。返回ID为1的用户未完成的带有“P1”标签的任务。 -todoList.completeTask(5, 1); // 不做任何操作,因为任务1不属于用户5。 -todoList.completeTask(1, 2); // 将任务2标记为已完成。 -todoList.getTasksForTag(1, "P1"); // 返回["Task3"]。返回ID为1的用户未完成的带有“P1”标签的任务。 - // 注意,现在不包括 “Task2” ,因为它已经被标记为已完成。 +TodoList todoList = new TodoList(); +todoList.addTask(1, "Task1", 50, []); // 返回1。为ID为1的用户添加一个新任务。 +todoList.addTask(1, "Task2", 100, ["P1"]); // 返回2。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 +todoList.getAllTasks(1); // 返回["Task1", "Task2"]。用户1目前有两个未完成的任务。 +todoList.getAllTasks(5); // 返回[]。用户5目前没有任务。 +todoList.addTask(1, "Task3", 30, ["P1"]); // 返回3。为ID为1的用户添加另一个任务,并给它添加标签“P1”。 +todoList.getTasksForTag(1, "P1"); // 返回["Task3", "Task2"]。返回ID为1的用户未完成的带有“P1”标签的任务。 +todoList.completeTask(5, 1); // 不做任何操作,因为任务1不属于用户5。 +todoList.completeTask(1, 2); // 将任务2标记为已完成。 +todoList.getTasksForTag(1, "P1"); // 返回["Task3"]。返回ID为1的用户未完成的带有“P1”标签的任务。 + // 注意,现在不包括 “Task2” ,因为它已经被标记为已完成。 todoList.getAllTasks(1); // 返回["Task3", "Task1"]。用户1现在有两个未完成的任务。MKAverage obj = new MKAverage(3, 1); +
MKAverage obj = new MKAverage(3, 1); obj.addElement(3); // current elements are [3] obj.addElement(1); // current elements are [3,1] obj.calculateMKAverage(); // return -1, because m = 3 and only 2 elements exist. diff --git a/solution/2300-2399/2349.Design a Number Container System/README_EN.md b/solution/2300-2399/2349.Design a Number Container System/README_EN.md index 8480f11edb6db..b55a94b3c5cfd 100644 --- a/solution/2300-2399/2349.Design a Number Container System/README_EN.md +++ b/solution/2300-2399/2349.Design a Number Container System/README_EN.md @@ -54,7 +54,7 @@ nc.change(1, 10); // Your container at index 1 will be filled with number 10. nc.change(3, 10); // Your container at index 3 will be filled with number 10. nc.change(5, 10); // Your container at index 5 will be filled with number 10. nc.find(10); // Number 10 is at the indices 1, 2, 3, and 5. Since the smallest index that is filled with 10 is 1, we return 1. -nc.change(1, 20); // Your container at index 1 will be filled with number 20. Note that index 1 was filled with 10 and then replaced with 20. +nc.change(1, 20); // Your container at index 1 will be filled with number 20. Note that index 1 was filled with 10 and then replaced with 20. nc.find(10); // Number 10 is at the indices 2, 3, and 5. The smallest index that is filled with 10 is 2. Therefore, we return 2.
Input: nums = [1,-1,-3,-2,3], k = 3, x = 2 Output: [-1,-2,-2] -Explanation: There are 3 subarrays with size k = 3. +Explanation: There are 3 subarrays with size k = 3. The first subarray isdiff --git a/solution/2700-2799/2749.Minimum Operations to Make the Integer Zero/README_EN.md b/solution/2700-2799/2749.Minimum Operations to Make the Integer Zero/README_EN.md index a017d3e80647a..45530dc18abf5 100644 --- a/solution/2700-2799/2749.Minimum Operations to Make the Integer Zero/README_EN.md +++ b/solution/2700-2799/2749.Minimum Operations to Make the Integer Zero/README_EN.md @@ -34,9 +34,9 @@ tags: Input: num1 = 3, num2 = -2 Output: 3 Explanation: We can make 3 equal to 0 with the following operations: -- We choose i = 2 and substract 22 + (-2) from 3, 3 - (4 + (-2)) = 1. -- We choose i = 2 and substract 22 + (-2) from 1, 1 - (4 + (-2)) = -1. -- We choose i = 0 and substract 20 + (-2) from -1, (-1) - (1 + (-2)) = 0. +- We choose i = 2 and subtract 22 + (-2) from 3, 3 - (4 + (-2)) = 1. +- We choose i = 2 and subtract 22 + (-2) from 1, 1 - (4 + (-2)) = -1. +- We choose i = 0 and subtract 20 + (-2) from -1, (-1) - (1 + (-2)) = 0. It can be proven, that 3 is the minimum number of operations that we need to perform.[1, -1, -3]
and the 2nd smallest negative integer is -1. The second subarray is[-1, -3, -2]
and the 2nd smallest negative integer is -2. The third subarray is[-3, -2, 3]
and the 2nd smallest negative integer is -2.
Input: nums = [5,4,2,4] Output: 8 -Explanation: +Explanation: Continuous subarray of size 1: [5], [4], [2], [4]. Continuous subarray of size 2: [5,4], [4,2], [2,4]. Continuous subarray of size 3: [4,2,4]. @@ -55,7 +55,7 @@ It can be shown that there are no more continuous subarrays.diff --git a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md index fb1c71f35d61f..a770f63c0f35c 100644 --- a/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md +++ b/solution/2800-2899/2817.Minimum Absolute Difference Between Elements With Constraint/README_EN.md @@ -34,8 +34,8 @@ tags:Input: nums = [1,2,3] Output: 6 -Explanation: +Explanation: Continuous subarray of size 1: [1], [2], [3]. Continuous subarray of size 2: [1,2], [2,3]. Continuous subarray of size 3: [1,2,3]. diff --git a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md index 0243dafa27604..ca4df4150344f 100644 --- a/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md +++ b/solution/2700-2799/2763.Sum of Imbalance Numbers of All Subarrays/README_EN.md @@ -43,7 +43,7 @@ tags: - Subarray [3, 1] with an imbalance number of 1. - Subarray [3, 1, 4] with an imbalance number of 1. - Subarray [1, 4] with an imbalance number of 1. -The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3. +The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 3.Example 2:
@@ -55,8 +55,8 @@ The imbalance number of all other subarrays is 0. Hence, the sum of imbalance nu - Subarray [1, 3] with an imbalance number of 1. - Subarray [1, 3, 3] with an imbalance number of 1. - Subarray [1, 3, 3, 3] with an imbalance number of 1. -- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2. -- Subarray [3, 3, 3, 5] with an imbalance number of 1. +- Subarray [1, 3, 3, 3, 5] with an imbalance number of 2. +- Subarray [3, 3, 3, 5] with an imbalance number of 1. - Subarray [3, 3, 5] with an imbalance number of 1. - Subarray [3, 5] with an imbalance number of 1. The imbalance number of all other subarrays is 0. Hence, the sum of imbalance numbers of all the subarrays of nums is 8.
Input: nums = [4,3,2,4], x = 2 Output: 0 -Explanation: We can select nums[0] = 4 and nums[3] = 4. -They are at least 2 indices apart, and their absolute difference is the minimum, 0. +Explanation: We can select nums[0] = 4 and nums[3] = 4. +They are at least 2 indices apart, and their absolute difference is the minimum, 0. It can be shown that 0 is the optimal answer.diff --git a/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md b/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md index ba80832e5d3d5..f48d4d484d420 100644 --- a/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md +++ b/solution/3200-3299/3278.Find Candidates for Data Scientist Position II/README.md @@ -53,6 +53,7 @@ tags:
100
分 开始。10
分。5
分。100
points10
points for each skill where proficiency > importance5
points for each skill where proficiency < importance结果表以 student_id,subject 升序排序。
diff --git a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md index 1be8c45c55821..ad4685f9375f9 100644 --- a/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md +++ b/solution/3400-3499/3422.Minimum Operations to Make Subarray Elements Equal/README.md @@ -6,7 +6,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3422.Mi -# [3422. Minimum Operations to Make Subarray Elements Equal 🔒](https://leetcode.cn/problems/minimum-operations-to-make-subarray-elements-equal) +# [3422. 将子数组元素变为相等所需的最小操作数 🔒](https://leetcode.cn/problems/minimum-operations-to-make-subarray-elements-equal) [English Version](/solution/3400-3499/3422.Minimum%20Operations%20to%20Make%20Subarray%20Elements%20Equal/README_EN.md) @@ -14,49 +14,51 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3400-3499/3422.Mi -You are given an integer array nums
and an integer k
. You can perform the following operation any number of times:
给定一个整数数组 nums
和一个整数 k
。你可以进行任意次以下操作:
nums
by 1.nums
的任何元素增加或减少 1。Return the minimum number of operations required to ensure that at least one subarray of size k
in nums
has all elements equal.
返回确保 至少 有一个大小为 k
的 nums
中的 子数组 的所有元素都相等的所需的 最小 操作数。
-
Example 1:
+ +示例 1:
Input: nums = [4,-3,2,1,-4,6], k = 3
+输入:nums = [4,-3,2,1,-4,6], k = 3
-Output: 5
+输出:5
-Explanation:
+解释:
nums[1]
. The resulting array is [4, 1, 2, 1, -4, 6]
.nums[2]
. The resulting array is [4, 1, 1, 1, -4, 6]
.[1, 1, 1]
of size k = 3
with all elements equal. Hence, the answer is 5.nums[1]
增加 4。结果数组为 [4, 1, 2, 1, -4, 6]
。nums[2]
减少 1。结果数组为 [4, 1, 1, 1, -4, 6]
。k = 3
的子数组 [1, 1, 1]
,所有元素都想等。因此,答案为 5。Example 2:
+示例 2:
Input: nums = [-2,-2,3,1,4], k = 2
+输入:nums = [-2,-2,3,1,4], k = 2
-Output: 0
+输出:0
-Explanation:
+解释:
The subarray [-2, -2]
of size k = 2
already contains all equal elements, so no operations are needed. Hence, the answer is 0.
大小为 k = 2
的子数组 [-2, -2]
已经包含了所有相等的元素,所以不需要操作。因此答案为 0。
-
Constraints:
+ +提示:
2 <= nums.length <= 105