diff --git a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README.md b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README.md index 80c547816a75f..5c7c3af446d38 100644 --- a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README.md +++ b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README.md @@ -72,7 +72,7 @@ 最后返回 `f4` 即可。 -时间复杂度 $O(n),ドル空间复杂度 $O(1)$。其中 $n$ 为数组 `prices` 的长度。 +时间复杂度 $O(n),ドル其中 $n$ 为数组 `prices` 的长度。空间复杂度 $O(1)$。 @@ -183,8 +183,7 @@ func max(a, b int) int { public class Solution { public int MaxProfit(int[] prices) { int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0; - for (int i = 1; i < prices.Length; ++i) - { + for (int i = 1; i < prices.Length; ++i) { f1 = Math.Max(f1, -prices[i]); f2 = Math.Max(f2, f1 + prices[i]); f3 = Math.Max(f3, f2 - prices[i]); @@ -199,10 +198,7 @@ public class Solution { ```ts function maxProfit(prices: number[]): number { - let f1 = -prices[0], - f2 = 0, - f3 = -prices[0], - f4 = 0; + let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0]; for (let i = 1; i < prices.length; ++i) { f1 = Math.max(f1, -prices[i]); f2 = Math.max(f2, f1 + prices[i]); diff --git a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README_EN.md b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README_EN.md index 9bee3c828fccc..cde19a51bd06b 100644 --- a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README_EN.md +++ b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README_EN.md @@ -149,8 +149,7 @@ func max(a, b int) int { public class Solution { public int MaxProfit(int[] prices) { int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0; - for (int i = 1; i < prices.Length; ++i) - { + for (int i = 1; i < prices.Length; ++i) { f1 = Math.Max(f1, -prices[i]); f2 = Math.Max(f2, f1 + prices[i]); f3 = Math.Max(f3, f2 - prices[i]); @@ -165,10 +164,7 @@ public class Solution { ```ts function maxProfit(prices: number[]): number { - let f1 = -prices[0], - f2 = 0, - f3 = -prices[0], - f4 = 0; + let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0]; for (let i = 1; i < prices.length; ++i) { f1 = Math.max(f1, -prices[i]); f2 = Math.max(f2, f1 + prices[i]); diff --git a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.cs b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.cs index 6d22e0f413b3e..9ccd3bbfaf963 100644 --- a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.cs +++ b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.cs @@ -1,8 +1,7 @@ public class Solution { public int MaxProfit(int[] prices) { int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0; - for (int i = 1; i < prices.Length; ++i) - { + for (int i = 1; i < prices.Length; ++i) { f1 = Math.Max(f1, -prices[i]); f2 = Math.Max(f2, f1 + prices[i]); f3 = Math.Max(f3, f2 - prices[i]); diff --git a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.ts b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.ts index 023b86ebe2f54..0111c1af94d1a 100644 --- a/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.ts +++ b/solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.ts @@ -1,8 +1,5 @@ function maxProfit(prices: number[]): number { - let f1 = -prices[0], - f2 = 0, - f3 = -prices[0], - f4 = 0; + let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0]; for (let i = 1; i < prices.length; ++i) { f1 = Math.max(f1, -prices[i]); f2 = Math.max(f2, f1 + prices[i]); diff --git a/solution/0400-0499/0489.Robot Room Cleaner/README.md b/solution/0400-0499/0489.Robot Room Cleaner/README.md index cdc699d800e5c..7ff011027e14c 100644 --- a/solution/0400-0499/0489.Robot Room Cleaner/README.md +++ b/solution/0400-0499/0489.Robot Room Cleaner/README.md @@ -14,7 +14,8 @@

请利用提供的4个API编写让机器人清理整个房间的算法。

-
interface Robot {
+
+interface Robot {
  // 若下一个方格为空,则返回true,并移动至该方格
  // 若下一个方格为障碍物,则返回false,并停留在原地
  boolean move();
@@ -31,7 +32,10 @@
 
 

示例:

-
输入:
+

+ +
+输入:
 room = [
 [1,1,1,1,1,0,1,1],
 [1,1,1,1,1,0,1,1],
@@ -50,7 +54,7 @@ col = 3
 

注意:

    -
  1. 输入只用于初始化房间和机器人的位置。你需要“盲解”这个问题。换而言之,你必须在对房间和机器人位置一无所知的情况下,只使用4个给出的API解决问题。
  2. +
  3. 输入只用于初始化房间和机器人的位置。你需要"盲解"这个问题。换而言之,你必须在对房间和机器人位置一无所知的情况下,只使用4个给出的API解决问题。
  4. 扫地机器人的初始位置一定是空地。
  5. 扫地机器人的初始方向向上。
  6. 所有可抵达的格子都是相连的,亦即所有标记为1的格子机器人都可以抵达。
  7. diff --git a/solution/0400-0499/0489.Robot Room Cleaner/images/1695782910-iCEGqJ-image.png b/solution/0400-0499/0489.Robot Room Cleaner/images/1695782910-iCEGqJ-image.png new file mode 100644 index 0000000000000..738bde102d353 Binary files /dev/null and b/solution/0400-0499/0489.Robot Room Cleaner/images/1695782910-iCEGqJ-image.png differ diff --git a/solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md b/solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md index 7245a7b1490cc..278556f723250 100644 --- a/solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md +++ b/solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md @@ -4,7 +4,7 @@ ## Description -

    Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.

    +

    Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.

    Two arrays nums1 and nums2 are said to be distinct if:

    diff --git a/solution/2700-2799/2782.Number of Unique Categories/README.md b/solution/2700-2799/2782.Number of Unique Categories/README.md index 33710f6555d55..72b481e4e8d49 100644 --- a/solution/2700-2799/2782.Number of Unique Categories/README.md +++ b/solution/2700-2799/2782.Number of Unique Categories/README.md @@ -8,7 +8,7 @@

    现给定一个整数 n 和一个 CategoryHandler 类的对象 categoryHandler

    -

    n 个元素,编号从 0n - 1。每个元素都有一个类别,你的任务是找出唯一类别的数量。

    +

    n 个元素,编号从 0n - 1。每个元素都有一个类别,你的任务是找出唯一类别的数量。

    CategoryHandler 类包含以下方法,可能对你有帮助:

    @@ -16,7 +16,7 @@
  8. boolean haveSameCategory(integer a, integer b):如果 ab 属于相同的类别,则返回 true,否则返回 false。同时,如果 ab 不是有效的数字(即大于等于 n 或小于 0),它也会返回 false
  9. -

    返回唯一类别的数量。

    +

    返回 唯一类别的数量

    diff --git a/solution/2700-2799/2782.Number of Unique Categories/README_EN.md b/solution/2700-2799/2782.Number of Unique Categories/README_EN.md index b688d935b50e9..853dd9dee9682 100644 --- a/solution/2700-2799/2782.Number of Unique Categories/README_EN.md +++ b/solution/2700-2799/2782.Number of Unique Categories/README_EN.md @@ -6,7 +6,7 @@

    You are given an integer n and an object categoryHandler of class CategoryHandler.

    -

    There are nelements, numbered from 0 to n - 1. Each element has a category, and your task is to find the number of unique categories.

    +

    There are n elements, numbered from 0 to n - 1. Each element has a category, and your task is to find the number of unique categories.

    The class CategoryHandler contains the following function, which may help you:

    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 f57bc78fdf131..9f4c27c5adb31 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. 可以被 K 整除连通块的最大数目](https://leetcode.com/problems/maximum-number-of-k-divisible-components/) +# [2872. 可以被 K 整除连通块的最大数目](https://leetcode.cn/problems/maximum-number-of-k-divisible-components/) [English Version](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md) diff --git a/solution/README.md b/solution/README.md index ae74e7cfd0dc4..8ed7fec1e0434 100644 --- a/solution/README.md +++ b/solution/README.md @@ -174,7 +174,7 @@ | 0161 | [相隔为 1 的编辑距离](/solution/0100-0199/0161.One%20Edit%20Distance/README.md) | `双指针`,`字符串` | 中等 | 🔒 | | 0162 | [寻找峰值](/solution/0100-0199/0162.Find%20Peak%20Element/README.md) | `数组`,`二分查找` | 中等 | | | 0163 | [缺失的区间](/solution/0100-0199/0163.Missing%20Ranges/README.md) | `数组` | 简单 | 🔒 | -| 0164 | [最大间距](/solution/0100-0199/0164.Maximum%20Gap/README.md) | `数组`,`桶排序`,`基数排序`,`排序` | 困难 | | +| 0164 | [最大间距](/solution/0100-0199/0164.Maximum%20Gap/README.md) | `数组`,`桶排序`,`基数排序`,`排序` | 中等 | | | 0165 | [比较版本号](/solution/0100-0199/0165.Compare%20Version%20Numbers/README.md) | `双指针`,`字符串` | 中等 | | | 0166 | [分数到小数](/solution/0100-0199/0166.Fraction%20to%20Recurring%20Decimal/README.md) | `哈希表`,`数学`,`字符串` | 中等 | | | 0167 | [两数之和 II - 输入有序数组](/solution/0100-0199/0167.Two%20Sum%20II%20-%20Input%20Array%20Is%20Sorted/README.md) | `数组`,`双指针`,`二分查找` | 中等 | | @@ -2642,7 +2642,7 @@ | 2629 | [复合函数](/solution/2600-2699/2629.Function%20Composition/README.md) | | 简单 | | | 2630 | [记忆函数 II](/solution/2600-2699/2630.Memoize%20II/README.md) | | 困难 | | | 2631 | [分组](/solution/2600-2699/2631.Group%20By/README.md) | | 中等 | | -| 2632 | [柯里化](/solution/2600-2699/2632.Curry/README.md) | | 中等 | 🔒 | +| 2632 | [柯里化](/solution/2600-2699/2632.Curry/README.md) | | 困难 | 🔒 | | 2633 | [将对象转换为 JSON 字符串](/solution/2600-2699/2633.Convert%20Object%20to%20JSON%20String/README.md) | | 中等 | 🔒 | | 2634 | [过滤数组中的元素](/solution/2600-2699/2634.Filter%20Elements%20from%20Array/README.md) | | 简单 | | | 2635 | [转换数组中的每个元素](/solution/2600-2699/2635.Apply%20Transform%20Over%20Each%20Element%20in%20Array/README.md) | | 简单 | | @@ -2807,7 +2807,7 @@ | 2794 | [从两个数组中创建对象](/solution/2700-2799/2794.Create%20Object%20from%20Two%20Arrays/README.md) | | 简单 | 🔒 | | 2795 | [并行执行 Promise 以获取独有的结果](/solution/2700-2799/2795.Parallel%20Execution%20of%20Promises%20for%20Individual%20Results%20Retrieval/README.md) | | 中等 | 🔒 | | 2796 | [重复字符串](/solution/2700-2799/2796.Repeat%20String/README.md) | | 简单 | 🔒 | -| 2797 | [带有占位符的部分函数](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README.md) | | 简单 | 🔒 | +| 2797 | [带有占位符的部分函数](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README.md) | | 中等 | 🔒 | | 2798 | [满足目标工作时长的员工数目](/solution/2700-2799/2798.Number%20of%20Employees%20Who%20Met%20the%20Target/README.md) | `数组`,`枚举` | 简单 | 第 356 场周赛 | | 2799 | [统计完全子数组的数目](/solution/2700-2799/2799.Count%20Complete%20Subarrays%20in%20an%20Array/README.md) | `数组`,`哈希表`,`滑动窗口` | 中等 | 第 356 场周赛 | | 2800 | [包含三个字符串的最短字符串](/solution/2800-2899/2800.Shortest%20String%20That%20Contains%20Three%20Strings/README.md) | `贪心`,`字符串`,`枚举` | 中等 | 第 356 场周赛 | diff --git a/solution/README_EN.md b/solution/README_EN.md index 08b777f0e5010..74263b51eaf68 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -172,7 +172,7 @@ Press Control + F(or Command + F on | 0161 | [One Edit Distance](/solution/0100-0199/0161.One%20Edit%20Distance/README_EN.md) | `Two Pointers`,`String` | Medium | 🔒 | | 0162 | [Find Peak Element](/solution/0100-0199/0162.Find%20Peak%20Element/README_EN.md) | `Array`,`Binary Search` | Medium | | | 0163 | [Missing Ranges](/solution/0100-0199/0163.Missing%20Ranges/README_EN.md) | `Array` | Easy | 🔒 | -| 0164 | [Maximum Gap](/solution/0100-0199/0164.Maximum%20Gap/README_EN.md) | `Array`,`Bucket Sort`,`Radix Sort`,`Sorting` | Hard | | +| 0164 | [Maximum Gap](/solution/0100-0199/0164.Maximum%20Gap/README_EN.md) | `Array`,`Bucket Sort`,`Radix Sort`,`Sorting` | Medium | | | 0165 | [Compare Version Numbers](/solution/0100-0199/0165.Compare%20Version%20Numbers/README_EN.md) | `Two Pointers`,`String` | Medium | | | 0166 | [Fraction to Recurring Decimal](/solution/0100-0199/0166.Fraction%20to%20Recurring%20Decimal/README_EN.md) | `Hash Table`,`Math`,`String` | Medium | | | 0167 | [Two Sum II - Input Array Is Sorted](/solution/0100-0199/0167.Two%20Sum%20II%20-%20Input%20Array%20Is%20Sorted/README_EN.md) | `Array`,`Two Pointers`,`Binary Search` | Medium | | @@ -2640,7 +2640,7 @@ Press Control + F(or Command + F on | 2629 | [Function Composition](/solution/2600-2699/2629.Function%20Composition/README_EN.md) | | Easy | | | 2630 | [Memoize II](/solution/2600-2699/2630.Memoize%20II/README_EN.md) | | Hard | | | 2631 | [Group By](/solution/2600-2699/2631.Group%20By/README_EN.md) | | Medium | | -| 2632 | [Curry](/solution/2600-2699/2632.Curry/README_EN.md) | | Medium | 🔒 | +| 2632 | [Curry](/solution/2600-2699/2632.Curry/README_EN.md) | | Hard | 🔒 | | 2633 | [Convert Object to JSON String](/solution/2600-2699/2633.Convert%20Object%20to%20JSON%20String/README_EN.md) | | Medium | 🔒 | | 2634 | [Filter Elements from Array](/solution/2600-2699/2634.Filter%20Elements%20from%20Array/README_EN.md) | | Easy | | | 2635 | [Apply Transform Over Each Element in Array](/solution/2600-2699/2635.Apply%20Transform%20Over%20Each%20Element%20in%20Array/README_EN.md) | | Easy | | @@ -2805,7 +2805,7 @@ Press Control + F(or Command + F on | 2794 | [Create Object from Two Arrays](/solution/2700-2799/2794.Create%20Object%20from%20Two%20Arrays/README_EN.md) | | Easy | 🔒 | | 2795 | [Parallel Execution of Promises for Individual Results Retrieval](/solution/2700-2799/2795.Parallel%20Execution%20of%20Promises%20for%20Individual%20Results%20Retrieval/README_EN.md) | | Medium | 🔒 | | 2796 | [Repeat String](/solution/2700-2799/2796.Repeat%20String/README_EN.md) | | Easy | 🔒 | -| 2797 | [Partial Function with Placeholders](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README_EN.md) | | Easy | 🔒 | +| 2797 | [Partial Function with Placeholders](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README_EN.md) | | Medium | 🔒 | | 2798 | [Number of Employees Who Met the Target](/solution/2700-2799/2798.Number%20of%20Employees%20Who%20Met%20the%20Target/README_EN.md) | `Array`,`Enumeration` | Easy | Weekly Contest 356 | | 2799 | [Count Complete Subarrays in an Array](/solution/2700-2799/2799.Count%20Complete%20Subarrays%20in%20an%20Array/README_EN.md) | `Array`,`Hash Table`,`Sliding Window` | Medium | Weekly Contest 356 | | 2800 | [Shortest String That Contains Three Strings](/solution/2800-2899/2800.Shortest%20String%20That%20Contains%20Three%20Strings/README_EN.md) | `Greedy`,`String`,`Enumeration` | Medium | Weekly Contest 356 |

    AltStyle によって変換されたページ (->オリジナル) /