Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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‎

Lines changed: 3 additions & 7 deletions
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‎

Lines changed: 2 additions & 6 deletions
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‎

Lines changed: 1 addition & 2 deletions
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‎

Lines changed: 1 addition & 4 deletions
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‎

Lines changed: 7 additions & 3 deletions
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>
50.3 KB
Loading[フレーム]

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

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 2 additions & 2 deletions
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‎

Lines changed: 1 addition & 1 deletion
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‎

Lines changed: 1 addition & 1 deletion
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

0 commit comments

Comments
(0)

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