Skip to content

Commit 6b87938

Browse files
yanglbmeidoocs
andauthored
chore: update lc problems (#1739)
* chore: update lc problems * chore: optimised images with calibre/image-actions --------- Co-authored-by: Doocs Bot <doocs-bot@outlook.com>
1 parent d783956 commit 6b87938

File tree

12 files changed

+25
-33
lines changed

12 files changed

+25
-33
lines changed

solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README.md

+3-7
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272

7373
最后返回 `f4` 即可。
7474

75-
时间复杂度 $O(n)$,空间复杂度 $O(1)$。其中 $n$ 为数组 `prices` 的长度。
75+
时间复杂度 $O(n)$,其中 $n$ 为数组 `prices` 的长度。空间复杂度 $O(1)$
7676

7777
<!-- tabs:start -->
7878

@@ -183,8 +183,7 @@ func max(a, b int) int {
183183
public class Solution {
184184
public int MaxProfit(int[] prices) {
185185
int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0;
186-
for (int i = 1; i < prices.Length; ++i)
187-
{
186+
for (int i = 1; i < prices.Length; ++i) {
188187
f1 = Math.Max(f1, -prices[i]);
189188
f2 = Math.Max(f2, f1 + prices[i]);
190189
f3 = Math.Max(f3, f2 - prices[i]);
@@ -199,10 +198,7 @@ public class Solution {
199198

200199
```ts
201200
function maxProfit(prices: number[]): number {
202-
let f1 = -prices[0],
203-
f2 = 0,
204-
f3 = -prices[0],
205-
f4 = 0;
201+
let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0];
206202
for (let i = 1; i < prices.length; ++i) {
207203
f1 = Math.max(f1, -prices[i]);
208204
f2 = Math.max(f2, f1 + prices[i]);

solution/0100-0199/0123.Best Time to Buy and Sell Stock III/README_EN.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,7 @@ func max(a, b int) int {
149149
public class Solution {
150150
public int MaxProfit(int[] prices) {
151151
int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0;
152-
for (int i = 1; i < prices.Length; ++i)
153-
{
152+
for (int i = 1; i < prices.Length; ++i) {
154153
f1 = Math.Max(f1, -prices[i]);
155154
f2 = Math.Max(f2, f1 + prices[i]);
156155
f3 = Math.Max(f3, f2 - prices[i]);
@@ -165,10 +164,7 @@ public class Solution {
165164

166165
```ts
167166
function maxProfit(prices: number[]): number {
168-
let f1 = -prices[0],
169-
f2 = 0,
170-
f3 = -prices[0],
171-
f4 = 0;
167+
let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0];
172168
for (let i = 1; i < prices.length; ++i) {
173169
f1 = Math.max(f1, -prices[i]);
174170
f2 = Math.max(f2, f1 + prices[i]);

solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
public class Solution {
22
public int MaxProfit(int[] prices) {
33
int f1 = -prices[0], f2 = 0, f3 = -prices[0], f4 = 0;
4-
for (int i = 1; i < prices.Length; ++i)
5-
{
4+
for (int i = 1; i < prices.Length; ++i) {
65
f1 = Math.Max(f1, -prices[i]);
76
f2 = Math.Max(f2, f1 + prices[i]);
87
f3 = Math.Max(f3, f2 - prices[i]);

solution/0100-0199/0123.Best Time to Buy and Sell Stock III/Solution.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
function maxProfit(prices: number[]): number {
2-
let f1 = -prices[0],
3-
f2 = 0,
4-
f3 = -prices[0],
5-
f4 = 0;
2+
let [f1, f2, f3, f4] = [-prices[0], 0, -prices[0], 0];
63
for (let i = 1; i < prices.length; ++i) {
74
f1 = Math.max(f1, -prices[i]);
85
f2 = Math.max(f2, f1 + prices[i]);

solution/0400-0499/0489.Robot Room Cleaner/README.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
<p>请利用提供的4个API编写让机器人清理整个房间的算法。</p>
1616

17-
<pre>interface Robot {
17+
<pre>
18+
interface Robot {
1819
&nbsp; // 若下一个方格为空,则返回true,并移动至该方格
1920
&nbsp; // 若下一个方格为障碍物,则返回false,并停留在原地
2021
&nbsp; boolean move();
@@ -31,7 +32,10 @@
3132

3233
<p><strong>示例:</strong></p>
3334

34-
<pre><strong>输入:</strong>
35+
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0489.Robot%20Room%20Cleaner/images/1695782910-iCEGqJ-image.png" style="width: 644px; height: 405px;" /></strong></p>
36+
37+
<pre>
38+
<strong>输入:</strong>
3539
room = [
3640
[1,1,1,1,1,0,1,1],
3741
[1,1,1,1,1,0,1,1],
@@ -50,7 +54,7 @@ col = 3
5054
<p><strong>注意:</strong></p>
5155

5256
<ol>
53-
<li>输入只用于初始化房间和机器人的位置。你需要&ldquo;盲解&rdquo;这个问题。换而言之,你必须在对房间和机器人位置一无所知的情况下,只使用4个给出的API解决问题。&nbsp;</li>
57+
<li>输入只用于初始化房间和机器人的位置。你需要“盲解”这个问题。换而言之,你必须在对房间和机器人位置一无所知的情况下,只使用4个给出的API解决问题。&nbsp;</li>
5458
<li>扫地机器人的初始位置一定是空地。</li>
5559
<li>扫地机器人的初始方向向上。</li>
5660
<li>所有可抵达的格子都是相连的,亦即所有标记为1的格子机器人都可以抵达。</li>
Loading

solution/2200-2299/2261.K Divisible Elements Subarrays/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>Given an integer array <code>nums</code> and two integers <code>k</code> and <code>p</code>, return <em>the number of <strong>distinct subarrays,</strong> which have <strong>at most</strong></em> <code>k</code> <em>elements </em>that are&nbsp;<em>&nbsp;divisible by</em> <code>p</code>.</p>
7+
<p>Given an integer array <code>nums</code> and two integers <code>k</code> and <code>p</code>, return <em>the number of <strong>distinct subarrays,</strong> which have <strong>at most</strong></em> <code>k</code> <em>elements </em>that are <em>divisible by</em> <code>p</code>.</p>
88

99
<p>Two arrays <code>nums1</code> and <code>nums2</code> are said to be <strong>distinct</strong> if:</p>
1010

solution/2700-2799/2782.Number of Unique Categories/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88

99
<p>现给定一个整数 <code>n</code> 和一个 <code>CategoryHandler</code> 类的对象 <code>categoryHandler</code> 。</p>
1010

11-
<p>有 <code>n</code> 个元素,编号从 <code>0</code> 到 <code>n - 1</code>。每个元素都有一个类别,你的任务是找出唯一类别的数量。</p>
11+
<p>有 <code>n&nbsp;</code> 个元素,编号从 <code>0</code> 到 <code>n - 1</code>。每个元素都有一个类别,你的任务是找出唯一类别的数量。</p>
1212

1313
<p><code>CategoryHandler</code> 类包含以下方法,可能对你有帮助:</p>
1414

1515
<ul>
1616
<li><code>boolean haveSameCategory(integer a, integer b)</code>:如果 <code>a</code> 和 <code>b</code> 属于相同的类别,则返回 <code>true</code>,否则返回 <code>false</code>。同时,如果 <code>a</code> 或 <code>b</code> 不是有效的数字(即大于等于 <code>n</code> 或小于 <code>0</code>),它也会返回 <code>false</code>。</li>
1717
</ul>
1818

19-
<p>返回唯一类别的数量。</p>
19+
<p>返回&nbsp;<em>唯一类别的数量</em>。</p>
2020

2121
<p>&nbsp;</p>
2222

solution/2700-2799/2782.Number of Unique Categories/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<p>You are given an integer <code>n</code> and an object <code>categoryHandler</code> of class <code>CategoryHandler</code>.</p>
88

9-
<p>There are <code>n</code>elements, numbered from <code>0</code> to <code>n - 1</code>. Each element has a category, and your task is to find the number of unique categories.</p>
9+
<p>There are <code>n&nbsp;</code>elements, numbered from <code>0</code> to <code>n - 1</code>. Each element has a category, and your task is to find the number of unique categories.</p>
1010

1111
<p>The class <code>CategoryHandler</code> contains the following function, which may help you:</p>
1212

solution/2800-2899/2872.Maximum Number of K-Divisible Components/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# [2872. 可以被 K 整除连通块的最大数目](https://leetcode.com/problems/maximum-number-of-k-divisible-components/)
1+
# [2872. 可以被 K 整除连通块的最大数目](https://leetcode.cn/problems/maximum-number-of-k-divisible-components/)
22

33
[English Version](/solution/2800-2899/2872.Maximum%20Number%20of%20K-Divisible%20Components/README_EN.md)
44

solution/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
| 0161 | [相隔为 1 的编辑距离](/solution/0100-0199/0161.One%20Edit%20Distance/README.md) | `双指针`,`字符串` | 中等 | 🔒 |
175175
| 0162 | [寻找峰值](/solution/0100-0199/0162.Find%20Peak%20Element/README.md) | `数组`,`二分查找` | 中等 | |
176176
| 0163 | [缺失的区间](/solution/0100-0199/0163.Missing%20Ranges/README.md) | `数组` | 简单 | 🔒 |
177-
| 0164 | [最大间距](/solution/0100-0199/0164.Maximum%20Gap/README.md) | `数组`,`桶排序`,`基数排序`,`排序` | 困难 | |
177+
| 0164 | [最大间距](/solution/0100-0199/0164.Maximum%20Gap/README.md) | `数组`,`桶排序`,`基数排序`,`排序` | 中等 | |
178178
| 0165 | [比较版本号](/solution/0100-0199/0165.Compare%20Version%20Numbers/README.md) | `双指针`,`字符串` | 中等 | |
179179
| 0166 | [分数到小数](/solution/0100-0199/0166.Fraction%20to%20Recurring%20Decimal/README.md) | `哈希表`,`数学`,`字符串` | 中等 | |
180180
| 0167 | [两数之和 II - 输入有序数组](/solution/0100-0199/0167.Two%20Sum%20II%20-%20Input%20Array%20Is%20Sorted/README.md) | `数组`,`双指针`,`二分查找` | 中等 | |
@@ -2642,7 +2642,7 @@
26422642
| 2629 | [复合函数](/solution/2600-2699/2629.Function%20Composition/README.md) | | 简单 | |
26432643
| 2630 | [记忆函数 II](/solution/2600-2699/2630.Memoize%20II/README.md) | | 困难 | |
26442644
| 2631 | [分组](/solution/2600-2699/2631.Group%20By/README.md) | | 中等 | |
2645-
| 2632 | [柯里化](/solution/2600-2699/2632.Curry/README.md) | | 中等 | 🔒 |
2645+
| 2632 | [柯里化](/solution/2600-2699/2632.Curry/README.md) | | 困难 | 🔒 |
26462646
| 2633 | [将对象转换为 JSON 字符串](/solution/2600-2699/2633.Convert%20Object%20to%20JSON%20String/README.md) | | 中等 | 🔒 |
26472647
| 2634 | [过滤数组中的元素](/solution/2600-2699/2634.Filter%20Elements%20from%20Array/README.md) | | 简单 | |
26482648
| 2635 | [转换数组中的每个元素](/solution/2600-2699/2635.Apply%20Transform%20Over%20Each%20Element%20in%20Array/README.md) | | 简单 | |
@@ -2807,7 +2807,7 @@
28072807
| 2794 | [从两个数组中创建对象](/solution/2700-2799/2794.Create%20Object%20from%20Two%20Arrays/README.md) | | 简单 | 🔒 |
28082808
| 2795 | [并行执行 Promise 以获取独有的结果](/solution/2700-2799/2795.Parallel%20Execution%20of%20Promises%20for%20Individual%20Results%20Retrieval/README.md) | | 中等 | 🔒 |
28092809
| 2796 | [重复字符串](/solution/2700-2799/2796.Repeat%20String/README.md) | | 简单 | 🔒 |
2810-
| 2797 | [带有占位符的部分函数](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README.md) | | 简单 | 🔒 |
2810+
| 2797 | [带有占位符的部分函数](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README.md) | | 中等 | 🔒 |
28112811
| 2798 | [满足目标工作时长的员工数目](/solution/2700-2799/2798.Number%20of%20Employees%20Who%20Met%20the%20Target/README.md) | `数组`,`枚举` | 简单 | 第 356 场周赛 |
28122812
| 2799 | [统计完全子数组的数目](/solution/2700-2799/2799.Count%20Complete%20Subarrays%20in%20an%20Array/README.md) | `数组`,`哈希表`,`滑动窗口` | 中等 | 第 356 场周赛 |
28132813
| 2800 | [包含三个字符串的最短字符串](/solution/2800-2899/2800.Shortest%20String%20That%20Contains%20Three%20Strings/README.md) | `贪心`,`字符串`,`枚举` | 中等 | 第 356 场周赛 |

solution/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
172172
| 0161 | [One Edit Distance](/solution/0100-0199/0161.One%20Edit%20Distance/README_EN.md) | `Two Pointers`,`String` | Medium | 🔒 |
173173
| 0162 | [Find Peak Element](/solution/0100-0199/0162.Find%20Peak%20Element/README_EN.md) | `Array`,`Binary Search` | Medium | |
174174
| 0163 | [Missing Ranges](/solution/0100-0199/0163.Missing%20Ranges/README_EN.md) | `Array` | Easy | 🔒 |
175-
| 0164 | [Maximum Gap](/solution/0100-0199/0164.Maximum%20Gap/README_EN.md) | `Array`,`Bucket Sort`,`Radix Sort`,`Sorting` | Hard | |
175+
| 0164 | [Maximum Gap](/solution/0100-0199/0164.Maximum%20Gap/README_EN.md) | `Array`,`Bucket Sort`,`Radix Sort`,`Sorting` | Medium | |
176176
| 0165 | [Compare Version Numbers](/solution/0100-0199/0165.Compare%20Version%20Numbers/README_EN.md) | `Two Pointers`,`String` | Medium | |
177177
| 0166 | [Fraction to Recurring Decimal](/solution/0100-0199/0166.Fraction%20to%20Recurring%20Decimal/README_EN.md) | `Hash Table`,`Math`,`String` | Medium | |
178178
| 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 <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
26402640
| 2629 | [Function Composition](/solution/2600-2699/2629.Function%20Composition/README_EN.md) | | Easy | |
26412641
| 2630 | [Memoize II](/solution/2600-2699/2630.Memoize%20II/README_EN.md) | | Hard | |
26422642
| 2631 | [Group By](/solution/2600-2699/2631.Group%20By/README_EN.md) | | Medium | |
2643-
| 2632 | [Curry](/solution/2600-2699/2632.Curry/README_EN.md) | | Medium | 🔒 |
2643+
| 2632 | [Curry](/solution/2600-2699/2632.Curry/README_EN.md) | | Hard | 🔒 |
26442644
| 2633 | [Convert Object to JSON String](/solution/2600-2699/2633.Convert%20Object%20to%20JSON%20String/README_EN.md) | | Medium | 🔒 |
26452645
| 2634 | [Filter Elements from Array](/solution/2600-2699/2634.Filter%20Elements%20from%20Array/README_EN.md) | | Easy | |
26462646
| 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 <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
28052805
| 2794 | [Create Object from Two Arrays](/solution/2700-2799/2794.Create%20Object%20from%20Two%20Arrays/README_EN.md) | | Easy | 🔒 |
28062806
| 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 | 🔒 |
28072807
| 2796 | [Repeat String](/solution/2700-2799/2796.Repeat%20String/README_EN.md) | | Easy | 🔒 |
2808-
| 2797 | [Partial Function with Placeholders](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README_EN.md) | | Easy | 🔒 |
2808+
| 2797 | [Partial Function with Placeholders](/solution/2700-2799/2797.Partial%20Function%20with%20Placeholders/README_EN.md) | | Medium | 🔒 |
28092809
| 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 |
28102810
| 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 |
28112811
| 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 |

0 commit comments

Comments
 (0)