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 7cc03d3

Browse files
feat: update lc problems (#3763)
1 parent 54c5750 commit 7cc03d3

File tree

79 files changed

+568
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+568
-119
lines changed

‎lcp/LCP 12. 小张刷题计划/README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ class Solution {
224224
func minTime(_ time: [Int], _ m: Int) -> Int {
225225
var left = 0
226226
var right = time.reduce(0, +)
227-
227+
228228
while left < right {
229229
let mid = (left + right) / 2
230230
if check(mid, time, m) {
@@ -235,12 +235,12 @@ class Solution {
235235
}
236236
return left
237237
}
238-
238+
239239
private func check(_ t: Int, _ time: [Int], _ m: Int) -> Bool {
240240
var sum = 0
241241
var maxTime = 0
242242
var days = 1
243-
243+
244244
for x in time {
245245
sum += x
246246
maxTime = max(maxTime, x)

‎solution/0300-0399/0384.Shuffle an Array/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0300-0399/0384.Shuffle%20an%20Array/README.md
55
tags:
6+
- 设计
67
- 数组
78
- 数学
89
- 随机化

‎solution/0300-0399/0384.Shuffle an Array/README_EN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ comments: true
33
difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0300-0399/0384.Shuffle%20an%20Array/README_EN.md
55
tags:
6+
- Design
67
- Array
78
- Math
89
- Randomized

‎solution/0400-0499/0490.The Maze/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ tags:
2828

2929
<p>你可以 <strong>假定迷宫的边缘都是墙壁</strong>(参考示例)。</p>
3030

31-
<p></p>
31+
<p>&nbsp;</p>
3232

3333
<p><strong>示例 1:</strong></p>
3434
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0490.The%20Maze/images/maze1-1-grid.jpg" style="width: 573px; height: 573px;" />
3535
<pre>
3636
<strong>输入:</strong>maze = [[0,0,1,0,0],[0,0,0,0,0],[0,0,0,1,0],[1,1,0,1,1],[0,0,0,0,0]], start = [0,4], destination = [4,4]
3737
<strong>输出:</strong>true
38-
<strong>解释:</strong>一种可能的路径是 : 左 -> 下 -> 左 -> 下 -> 右 -> 下 -> 右。
38+
<strong>解释:</strong>一种可能的路径是 : 左 -&gt; 下 -&gt; 左 -&gt; 下 -&gt; 右 -&gt; 下 -&gt; 右。
3939
</pre>
4040

4141
<p><strong>示例 2:</strong></p>
@@ -53,19 +53,19 @@ tags:
5353
<strong>输出:</strong>false
5454
</pre>
5555

56-
<p></p>
56+
<p>&nbsp;</p>
5757

5858
<p><strong>提示:</strong></p>
5959

6060
<ul>
6161
<li><code>m == maze.length</code></li>
6262
<li><code>n == maze[i].length</code></li>
63-
<li><code>1 <= m, n <= 100</code></li>
63+
<li><code>1 &lt;= m, n &lt;= 100</code></li>
6464
<li><code>maze[i][j]</code> is <code>0</code> or <code>1</code>.</li>
6565
<li><code>start.length == 2</code></li>
6666
<li><code>destination.length == 2</code></li>
67-
<li><code>0 <= start<sub>row</sub>, destination<sub>row</sub> <= m</code></li>
68-
<li><code>0 <= start<sub>col</sub>, destination<sub>col</sub> <= n</code></li>
67+
<li><code>0 &lt;= start<sub>row</sub>, destination<sub>row</sub> &lt;&nbsp;m</code></li>
68+
<li><code>0 &lt;= start<sub>col</sub>, destination<sub>col</sub> &lt;&nbsp;n</code></li>
6969
<li>球和目的地都在空地上,且初始时它们不在同一位置</li>
7070
<li>迷宫 <strong>至少包括 2 块空地</strong></li>
7171
</ul>

‎solution/0400-0499/0490.The Maze/README_EN.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ tags:
5959
<li><code>maze[i][j]</code> is <code>0</code> or <code>1</code>.</li>
6060
<li><code>start.length == 2</code></li>
6161
<li><code>destination.length == 2</code></li>
62-
<li><code>0 &lt;= start<sub>row</sub>, destination<sub>row</sub> &lt;= m</code></li>
63-
<li><code>0 &lt;= start<sub>col</sub>, destination<sub>col</sub> &lt;= n</code></li>
62+
<li><code>0 &lt;= start<sub>row</sub>, destination<sub>row</sub> &lt; m</code></li>
63+
<li><code>0 &lt;= start<sub>col</sub>, destination<sub>col</sub> &lt; n</code></li>
6464
<li>Both the ball and the destination exist in an empty space, and they will not be in the same position initially.</li>
6565
<li>The maze contains <strong>at least 2 empty spaces</strong>.</li>
6666
</ul>

‎solution/0500-0599/0500.Keyboard Row/README.md‎

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ tags:
2020

2121
<p>给你一个字符串数组 <code>words</code> ,只返回可以使用在 <strong>美式键盘</strong> 同一行的字母打印出来的单词。键盘如下图所示。</p>
2222

23+
<p><strong>请注意</strong>,字符串&nbsp;<strong>不区分大小写</strong>,相同字母的大小写形式都被视为在同一行<strong>。</strong></p>
24+
2325
<p><strong>美式键盘</strong> 中:</p>
2426

2527
<ul>
@@ -30,36 +32,43 @@ tags:
3032

3133
<p><img alt="American keyboard" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0500-0599/0500.Keyboard%20Row/images/keyboard.png" style="width: 100%; max-width: 600px" /></p>
3234

33-
<p></p>
35+
<p>&nbsp;</p>
3436

3537
<p><strong>示例 1:</strong></p>
3638

37-
<pre>
38-
<strong>输入:</strong>words = ["Hello","Alaska","Dad","Peace"]
39-
<strong>输出:</strong>["Alaska","Dad"]
40-
</pre>
39+
<div class="example-block">
40+
<p><strong>输入:</strong><span class="example-io">words = ["Hello","Alaska","Dad","Peace"]</span></p>
41+
42+
<p><b>输出:</b><span class="example-io">["Alaska","Dad"]</span></p>
43+
44+
<p><strong>解释:</strong></p>
45+
46+
<p>由于不区分大小写,<code>"a"</code> 和&nbsp;<code>"A"</code> 都在美式键盘的第二行。</p>
47+
</div>
4148

4249
<p><strong>示例 2:</strong></p>
4350

44-
<pre>
45-
<strong>输入:</strong>words = ["omk"]
46-
<strong>输出:</strong>[]
47-
</pre>
51+
<div class="example-block">
52+
<p><span class="example-io"><b>输入:</b>words = ["omk"]</span></p>
53+
54+
<p><span class="example-io"><b>输出:</b>[]</span></p>
55+
</div>
56+
57+
<p><strong class="example">示例 3:</strong></p>
4858

49-
<p><strong>示例 3:</strong></p>
59+
<div class="example-block">
60+
<p><span class="example-io"><b>输入:</b></span><span class="example-io">words = ["adsdf","sfd"]</span></p>
5061

51-
<pre>
52-
<strong>输入:</strong>words = ["adsdf","sfd"]
53-
<strong>输出:</strong>["adsdf","sfd"]
54-
</pre>
62+
<p><span class="example-io"><b>输出:</b></span><span class="example-io">["adsdf","sfd"]</span></p>
63+
</div>
5564

56-
<p></p>
65+
<p>&nbsp;</p>
5766

5867
<p><strong>提示:</strong></p>
5968

6069
<ul>
61-
<li><code>1 <= words.length <= 20</code></li>
62-
<li><code>1 <= words[i].length <= 100</code></li>
70+
<li><code>1 &lt;= words.length &lt;= 20</code></li>
71+
<li><code>1 &lt;= words[i].length &lt;= 100</code></li>
6372
<li><code>words[i]</code> 由英文字母(小写和大写字母)组成</li>
6473
</ul>
6574

‎solution/0500-0599/0500.Keyboard Row/README_EN.md‎

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ tags:
2020

2121
<p>Given an array of strings <code>words</code>, return <em>the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below</em>.</p>
2222

23+
<p><strong>Note</strong> that the strings are <strong>case-insensitive</strong>, both lowercased and uppercased of the same letter are treated as if they are at the same row.</p>
24+
2325
<p>In the <strong>American keyboard</strong>:</p>
2426

2527
<ul>
@@ -31,24 +33,31 @@ tags:
3133
<p>&nbsp;</p>
3234
<p><strong class="example">Example 1:</strong></p>
3335

34-
<pre>
35-
<strong>Input:</strong> words = [&quot;Hello&quot;,&quot;Alaska&quot;,&quot;Dad&quot;,&quot;Peace&quot;]
36-
<strong>Output:</strong> [&quot;Alaska&quot;,&quot;Dad&quot;]
37-
</pre>
36+
<div class="example-block">
37+
<p><strong>Input:</strong> <span class="example-io">words = [&quot;Hello&quot;,&quot;Alaska&quot;,&quot;Dad&quot;,&quot;Peace&quot;]</span></p>
38+
39+
<p><strong>Output:</strong> <span class="example-io">[&quot;Alaska&quot;,&quot;Dad&quot;]</span></p>
40+
41+
<p><strong>Explanation:</strong></p>
42+
43+
<p>Both <code>&quot;a&quot;</code> and <code>&quot;A&quot;</code> are in the 2nd row of the American keyboard due to case insensitivity.</p>
44+
</div>
3845

3946
<p><strong class="example">Example 2:</strong></p>
4047

41-
<pre>
42-
<strong>Input:</strong> words = [&quot;omk&quot;]
43-
<strong>Output:</strong> []
44-
</pre>
48+
<div class="example-block">
49+
<p><strong>Input:</strong> <span class="example-io">words = [&quot;omk&quot;]</span></p>
50+
51+
<p><strong>Output:</strong> <span class="example-io">[]</span></p>
52+
</div>
4553

4654
<p><strong class="example">Example 3:</strong></p>
4755

48-
<pre>
49-
<strong>Input:</strong> words = [&quot;adsdf&quot;,&quot;sfd&quot;]
50-
<strong>Output:</strong> [&quot;adsdf&quot;,&quot;sfd&quot;]
51-
</pre>
56+
<div class="example-block">
57+
<p><strong>Input:</strong> <span class="example-io">words = [&quot;adsdf&quot;,&quot;sfd&quot;]</span></p>
58+
59+
<p><strong>Output:</strong> <span class="example-io">[&quot;adsdf&quot;,&quot;sfd&quot;]</span></p>
60+
</div>
5261

5362
<p>&nbsp;</p>
5463
<p><strong>Constraints:</strong></p>

‎solution/0700-0799/0777.Swap Adjacent in LR String/README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,24 @@ tags:
99

1010
<!-- problem:start -->
1111

12-
# [777. 在LR字符串中交换相邻字符](https://leetcode.cn/problems/swap-adjacent-in-lr-string)
12+
# [777. 在 LR 字符串中交换相邻字符](https://leetcode.cn/problems/swap-adjacent-in-lr-string)
1313

1414
[English Version](/solution/0700-0799/0777.Swap%20Adjacent%20in%20LR%20String/README_EN.md)
1515

1616
## 题目描述
1717

1818
<!-- description:start -->
1919

20-
<p>在一个由 <code>'L'</code> , <code>'R'</code> 和 <code>'X'</code> 三个字符组成的字符串(例如<code>"RXXLRXRXL"</code>)中进行移动操作。一次移动操作指用一个&nbsp;<code>"LX"</code>&nbsp;替换一个&nbsp;<code>"XL"</code>,或者用一个&nbsp;<code>"XR"</code>&nbsp;替换一个&nbsp;<code>"RX"</code>。现给定起始字符串&nbsp;<code>start</code>&nbsp;和结束字符串&nbsp;<code>end</code>,请编写代码,当且仅当存在一系列移动操作使得&nbsp;<code>start</code>&nbsp;可以转换成&nbsp;<code>end</code>&nbsp;时, 返回&nbsp;<code>True</code>。</p>
20+
<p>在一个由 <code>'L'</code> , <code>'R'</code> 和 <code>'X'</code> 三个字符组成的字符串(例如<code>"RXXLRXRXL"</code>)中进行移动操作。一次移动操作指用一个&nbsp;<code>"LX"</code>&nbsp;替换一个&nbsp;<code>"XL"</code>,或者用一个&nbsp;<code>"XR"</code>&nbsp;替换一个&nbsp;<code>"RX"</code>。现给定起始字符串&nbsp;<code>start</code>&nbsp;和结束字符串&nbsp;<code>result</code>,请编写代码,当且仅当存在一系列移动操作使得&nbsp;<code>start</code>&nbsp;可以转换成&nbsp;<code>result</code>&nbsp;时, 返回&nbsp;<code>True</code>。</p>
2121

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

2424
<p><strong class="example">示例 1:</strong></p>
2525

2626
<pre>
27-
<strong>输入:</strong>start = "RXXLRXRXL", end = "XRLXXRRLX"
27+
<strong>输入:</strong>start = "RXXLRXRXL", result = "XRLXXRRLX"
2828
<strong>输出:</strong>true
29-
<strong>解释:</strong>通过以下步骤我们可以将 start 转化为 end:
29+
<strong>解释:</strong>通过以下步骤我们可以将 start 转化为 result:
3030
RXXLRXRXL -&gt;
3131
XRXLRXRXL -&gt;
3232
XRLXRXRXL -&gt;
@@ -37,7 +37,7 @@ XRLXXRRLX
3737
<p><strong class="example">示例 2:</strong></p>
3838

3939
<pre>
40-
<strong>输入:</strong>start = "X", end = "L"
40+
<strong>输入:</strong>start = "X", result = "L"
4141
<strong>输出:</strong>false
4242
</pre>
4343

@@ -47,8 +47,8 @@ XRLXXRRLX
4747

4848
<ul>
4949
<li><code>1 &lt;= start.length&nbsp;&lt;= 10<sup>4</sup></code></li>
50-
<li><code>start.length == end.length</code></li>
51-
<li><code>start</code> 和&nbsp;<code>end</code>&nbsp;都只包含&nbsp;<code>'L'</code>, <code>'R'</code>&nbsp;或&nbsp;<code>'X'</code>。</li>
50+
<li><code>start.length == result.length</code></li>
51+
<li><code>start</code> 和&nbsp;<code>result</code>&nbsp;都只包含&nbsp;<code>'L'</code>, <code>'R'</code>&nbsp;或&nbsp;<code>'X'</code>。</li>
5252
</ul>
5353

5454
<!-- description:end -->

‎solution/0900-0999/0909.Snakes and Ladders/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ tags:
3636

3737
<p>如果 <code>board[r][c] != -1</code>&nbsp;,位于&nbsp;<code>r</code> 行 <code>c</code> 列的棋盘格中可能存在 "蛇" 或 "梯子"。那个蛇或梯子的目的地将会是 <code>board[r][c]</code>。编号为 <code>1</code> 和 <code>n<sup>2</sup></code> 的方格不是任何蛇或梯子的起点。</p>
3838

39-
<p>注意,玩家在每回合的前进过程中最多只能爬过蛇或梯子一次:就算目的地是另一条蛇或梯子的起点,玩家也 <strong>不能</strong> 继续移动。</p>
39+
<p>注意,玩家在每次掷骰的前进过程中最多只能爬过蛇或梯子一次:就算目的地是另一条蛇或梯子的起点,玩家也 <strong>不能</strong> 继续移动。</p>
4040

4141
<ul>
4242
<li>举个例子,假设棋盘是 <code>[[-1,4],[-1,3]]</code> ,第一次移动,玩家的目标方格是 <code>2</code> 。那么这个玩家将会顺着梯子到达方格 <code>3</code> ,但 <strong>不能</strong> 顺着方格 <code>3</code> 上的梯子前往方格 <code>4</code> 。(简单来说,类似飞行棋,玩家掷出骰子点数后移动对应格数,遇到单向的路径(即梯子或蛇)可以直接跳到路径的终点,但如果多个路径首尾相连,也不能连续跳多个路径)</li>
4343
</ul>
4444

45-
<p>返回达到编号为&nbsp;<code>n<sup>2</sup></code> 的方格所需的最少移动次数,如果不可能,则返回 <code>-1</code>。</p>
45+
<p>返回达到编号为&nbsp;<code>n<sup>2</sup></code> 的方格所需的最少掷骰次数,如果不可能,则返回 <code>-1</code>。</p>
4646

4747
<p>&nbsp;</p>
4848

‎solution/1000-1099/1095.Find in Mountain Array/README.md‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ tags:
5353
<p><strong>示例 1:</strong></p>
5454

5555
<pre>
56-
<strong>输入:</strong>array = [1,2,3,4,5,3,1], target = 3
56+
<strong>输入:</strong>mountainArr = [1,2,3,4,5,3,1], target = 3
5757
<strong>输出:</strong>2
5858
<strong>解释:</strong>3 在数组中出现了两次,下标分别为 2 和 5,我们返回最小的下标 2。</pre>
5959

6060
<p><strong>示例 2:</strong></p>
6161

6262
<pre>
63-
<strong>输入:</strong>array = [0,1,2,4,2,1], target = 3
63+
<strong>输入:</strong>mountainArr = [0,1,2,4,2,1], target = 3
6464
<strong>输出:</strong>-1
6565
<strong>解释:</strong>3 在数组中没有出现,返回 -1。
6666
</pre>
@@ -70,9 +70,9 @@ tags:
7070
<p><strong>提示:</strong></p>
7171

7272
<ul>
73-
<li><code>3 &lt;= mountain_arr.length() &lt;= 10<sup>4</sup></code></li>
73+
<li><code>3 &lt;= mountainArr.length() &lt;= 10<sup>4</sup></code></li>
7474
<li><code>0 &lt;= target &lt;= 10<sup>9</sup></code></li>
75-
<li><code>0 &lt;= mountain_arr.get(index) &lt;=&nbsp;10<sup>9</sup></code></li>
75+
<li><code>0 &lt;= mountainArr.get(index) &lt;=&nbsp;10<sup>9</sup></code></li>
7676
</ul>
7777

7878
<!-- description:end -->

0 commit comments

Comments
(0)

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