Skip to content

Commit b098694

Browse files
authored
feat: update lc problems (doocs#3438)
1 parent 547f88c commit b098694

File tree

51 files changed

+583
-116
lines changed

Some content is hidden

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

51 files changed

+583
-116
lines changed

solution/0100-0199/0147.Insertion Sort List/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,21 @@ tags:
3131

3232
<p>对链表进行插入排序。</p>
3333

34-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/Insertion-sort-example-300px.gif" /></p>
34+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/1724130387-qxfMwx-Insertion-sort-example-300px.gif" /></p>
3535

3636
<p>&nbsp;</p>
3737

3838
<p><strong>示例 1:</strong></p>
3939

40-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/sort1linked-list.jpg" /></p>
40+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/1724130414-QbPAjl-image.png" /></p>
4141

4242
<pre>
4343
<strong>输入:</strong> head = [4,2,1,3]
4444
<strong>输出:</strong> [1,2,3,4]</pre>
4545

4646
<p><strong>示例&nbsp;2:</strong></p>
4747

48-
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/sort2linked-list.jpg" /></p>
48+
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0100-0199/0147.Insertion%20Sort%20List/images/1724130432-zoOvdI-image.png" /></p>
4949

5050
<pre>
5151
<strong>输入:</strong> head = [-1,5,3,4,0]
Loading
Loading

solution/0200-0299/0208.Implement Trie (Prefix Tree)/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ tags:
1919

2020
<!-- description:start -->
2121

22-
<p><strong><a href="https://baike.baidu.com/item/字典树/9825209?fr=aladdin" target="_blank">Trie</a></strong>(发音类似 "try")或者说 <strong>前缀树</strong> 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补完和拼写检查。</p>
22+
<p><strong><a href="https://baike.baidu.com/item/字典树/9825209?fr=aladdin" target="_blank">Trie</a></strong>(发音类似 "try")或者说 <strong>前缀树</strong> 是一种树形数据结构,用于高效地存储和检索字符串数据集中的键。这一数据结构有相当多的应用情景,例如自动补全和拼写检查。</p>
2323

2424
<p>请你实现 Trie 类:</p>
2525

2626
<ul>
2727
<li><code>Trie()</code> 初始化前缀树对象。</li>
2828
<li><code>void insert(String word)</code> 向前缀树中插入字符串 <code>word</code> 。</li>
2929
<li><code>boolean search(String word)</code> 如果字符串 <code>word</code> 在前缀树中,返回 <code>true</code>(即,在检索之前已经插入);否则,返回 <code>false</code> 。</li>
30-
<li><code>boolean startsWith(String prefix)</code> 如果之前已经插入的字符串 <code>word</code> 的前缀之一为 <code>prefix</code> ,返回 <code>true</code> ;否则,返回 <code>false</code> 。</li>
30+
<li><code>boolean startsWith(String prefix)</code> 如果之前已经插入的字符串&nbsp;<code>word</code> 的前缀之一为 <code>prefix</code> ,返回 <code>true</code> ;否则,返回 <code>false</code> 。</li>
3131
</ul>
3232

33-
<p> </p>
33+
<p>&nbsp;</p>
3434

3535
<p><strong>示例:</strong></p>
3636

@@ -51,12 +51,12 @@ trie.insert("app");
5151
trie.search("app"); // 返回 True
5252
</pre>
5353

54-
<p> </p>
54+
<p>&nbsp;</p>
5555

5656
<p><strong>提示:</strong></p>
5757

5858
<ul>
59-
<li><code>1 <= word.length, prefix.length <= 2000</code></li>
59+
<li><code>1 &lt;= word.length, prefix.length &lt;= 2000</code></li>
6060
<li><code>word</code> 和 <code>prefix</code> 仅由小写英文字母组成</li>
6161
<li><code>insert</code>、<code>search</code> 和 <code>startsWith</code> 调用次数 <strong>总计</strong> 不超过 <code>3 * 10<sup>4</sup></code> 次</li>
6262
</ul>

solution/0300-0399/0379.Design Phone Directory/README.md

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -20,51 +20,47 @@ tags:
2020

2121
<!-- description:start -->
2222

23-
<p>设计一个电话目录管理系统,让它支持以下功能:</p>
23+
<p>设计一个电话目录管理系统,一开始有&nbsp;<code>maxNumbers</code>&nbsp;个位置能够储存号码。系统应该存储号码,检查某个位置是否为空,并清空给定的位置。</p>
2424

25-
<ol>
26-
<li><code>get</code>: 分配给用户一个未被使用的电话号码,获取失败请返回 -1</li>
27-
<li><code>check</code>: 检查指定的电话号码是否被使用</li>
28-
<li><code>release</code>: 释放掉一个电话号码,使其能够重新被分配</li>
29-
</ol>
25+
<p>实现&nbsp;<code>PhoneDirectory</code>&nbsp;类:</p>
3026

31-
<p>&nbsp;</p>
32-
33-
<p><strong>示例:</strong></p>
34-
35-
<pre>// 初始化电话目录,包括 3 个电话号码:0,1 和 2。
36-
PhoneDirectory directory = new PhoneDirectory(3);
37-
38-
// 可以返回任意未分配的号码,这里我们假设它返回 0。
39-
directory.get();
40-
41-
// 假设,函数返回 1。
42-
directory.get();
43-
44-
// 号码 2 未分配,所以返回为 true。
45-
directory.check(2);
46-
47-
// 返回 2,分配后,只剩一个号码未被分配。
48-
directory.get();
49-
50-
// 此时,号码 2 已经被分配,所以返回 false。
51-
directory.check(2);
27+
<ul>
28+
<li><code>PhoneDirectory(int maxNumbers)</code>&nbsp;电话目录初始有 <code>maxNumbers</code> 个可用位置。</li>
29+
<li><code>int get()</code> 提供一个未分配给任何人的号码。如果没有可用号码则返回&nbsp;<code>-1</code>。</li>
30+
<li><code>bool check(int number)</code>&nbsp;如果位置&nbsp;<code>number</code>&nbsp;可用返回 <code>true</code>&nbsp;否则返回&nbsp;<code>false</code>。</li>
31+
<li><code>void release(int number)</code> 回收或释放位置&nbsp;<code>number</code>。</li>
32+
</ul>
5233

53-
// 释放号码 2,将该号码变回未分配状态。
54-
directory.release(2);
34+
<p>&nbsp;</p>
5535

56-
// 号码 2 现在是未分配状态,所以返回 true。
57-
directory.check(2);
36+
<p><strong class="example">示例 1:</strong></p>
37+
38+
<pre>
39+
<strong>输入:</strong>
40+
["PhoneDirectory", "get", "get", "check", "get", "check", "release", "check"]
41+
[[3], [], [], [2], [], [2], [2], [2]]
42+
<strong>输出:</strong>
43+
[null, 0, 1, true, 2, false, null, true]
44+
45+
<strong>解释:</strong>
46+
PhoneDirectory phoneDirectory = new PhoneDirectory(3);
47+
phoneDirectory.get(); // 它可以返回任意可用的数字。这里我们假设它返回 0。
48+
phoneDirectory.get(); // 假设它返回 1。
49+
phoneDirectory.check(2); // 数字 2 可用,所以返回 true。
50+
phoneDirectory.get(); // 返回剩下的唯一一个数字 2。
51+
phoneDirectory.check(2); // 数字 2 不再可用,所以返回 false。
52+
phoneDirectory.release(2); // 将数字 2 释放回号码池。
53+
phoneDirectory.check(2); // 数字 2 重新可用,返回 true。
5854
</pre>
5955

6056
<p>&nbsp;</p>
6157

6258
<p><strong>提示:</strong></p>
6359

6460
<ul>
65-
<li><code>1 &lt;=&nbsp;maxNumbers &lt;= 10^4</code></li>
61+
<li><code>1 &lt;= maxNumbers &lt;= 10<sup>4</sup></code></li>
6662
<li><code>0 &lt;= number &lt; maxNumbers</code></li>
67-
<li>调用方法的总数处于区间 <code>[0 - 20000]</code> 之内</li>
63+
<li><code>get</code>,<code>check</code>&nbsp;和&nbsp;<code>release</code>&nbsp;最多被调用&nbsp;<code>2 * 10<sup>4</sup></code>&nbsp;次。</li>
6864
</ul>
6965

7066
<!-- description:end -->

solution/0300-0399/0391.Perfect Rectangle/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ tags:
5151
<ul>
5252
<li><code>1 &lt;= rectangles.length &lt;= 2 * 10<sup>4</sup></code></li>
5353
<li><code>rectangles[i].length == 4</code></li>
54-
<li><code>-10<sup>5</sup> &lt;= x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
54+
<li><code>-10<sup>5</sup> &lt;= x<sub>i</sub> &lt; a<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
55+
<li><code>-10<sup>5</sup> &lt;= y<sub>i</sub> &lt; b<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
5556
</ul>
5657

5758
<!-- description:end -->

solution/0300-0399/0391.Perfect Rectangle/README_EN.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ tags:
5252
<ul>
5353
<li><code>1 &lt;= rectangles.length &lt;= 2 * 10<sup>4</sup></code></li>
5454
<li><code>rectangles[i].length == 4</code></li>
55-
<li><code>-10<sup>5</sup> &lt;= x<sub>i</sub>, y<sub>i</sub>, a<sub>i</sub>, b<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
55+
<li><code>-10<sup>5</sup> &lt;= x<sub>i</sub> &lt; a<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
56+
<li><code>-10<sup>5</sup> &lt;= y<sub>i</sub> &lt; b<sub>i</sub> &lt;= 10<sup>5</sup></code></li>
5657
</ul>
5758

5859
<!-- description:end -->

solution/0600-0699/0616.Add Bold Tag in String/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Since now the four &lt;b&gt;&#39;s are consecutive, we merge them: &quot;&lt;b&g
6666
</ul>
6767

6868
<p>&nbsp;</p>
69-
<p><strong>Note:</strong> This question is the same as 758: <a href="https://leetcode.com/problems/bold-words-in-string/" target="_blank">https://leetcode.com/problems/bold-words-in-string/</a></p>
69+
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/bold-words-in-string/description/" target="_blank">758. Bold Words in String</a>.</p>
7070

7171
<!-- description:end -->
7272

solution/0700-0799/0756.Pyramid Transition Matrix/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ tags:
2626
<li>例如,<code>"ABC"</code>&nbsp;表示一个三角形图案,其中一个 <code>“C”</code> 块堆叠在一个&nbsp;<code>'A'</code>&nbsp;块(左)和一个&nbsp;<code>'B'</code>&nbsp;块(右)之上。请注意,这与 <code>"BAC"</code>&nbsp;不同,<code>"B"</code>&nbsp;在左下角,<code>"A"</code>&nbsp;在右下角。</li>
2727
</ul>
2828

29-
<p>你从底部的一排积木&nbsp;<code>bottom</code>&nbsp;开始,作为一个单一的字符串,你 <strong>必须</strong> 使用作为金字塔的底部。</p>
29+
<p>你从作为单个字符串给出的底部的一排积木&nbsp;<code>bottom</code>&nbsp;开始,<strong>必须</strong>&nbsp;将其作为金字塔的底部。</p>
3030

31-
<p>在给定&nbsp;<code>bottom</code>&nbsp;&nbsp;<code>allowed</code>&nbsp;的情况下,如果你能一直构建到金字塔顶部,使金字塔中的 <strong>每个三角形图案</strong> 都是允许的,则返回 <code>true</code> ,否则返回 <code>false</code> 。</p>
31+
<p>在给定&nbsp;<code>bottom</code>&nbsp;&nbsp;<code>allowed</code>&nbsp;的情况下,如果你能一直构建到金字塔顶部,使金字塔中的 <strong>每个三角形图案</strong> 都是在&nbsp;<code>allowed</code>&nbsp;中的,则返回 <code>true</code> ,否则返回 <code>false</code> 。</p>
3232

3333
<p>&nbsp;</p>
3434

@@ -39,7 +39,7 @@ tags:
3939
<pre>
4040
<strong>输入:</strong>bottom = "BCD", allowed = ["BCC","CDE","CEA","FFF"]
4141
<strong>输出:</strong>true
42-
<strong>解释:</strong>允许的三角形模式显示在右边
42+
<strong>解释:</strong>允许的三角形图案显示在右边
4343
从最底层(第 3 层)开始,我们可以在第 2 层构建“CE”,然后在第 1 层构建“E”。
4444
金字塔中有三种三角形图案,分别是 “BCC”、“CDE” 和 “CEA”。都是允许的。
4545
</pre>
@@ -51,8 +51,8 @@ tags:
5151
<pre>
5252
<strong>输入:</strong>bottom = "AAAA", allowed = ["AAB","AAC","BCD","BBE","DEF"]
5353
<strong>输出:</strong>false
54-
<strong>解释:</strong>允许的三角形模式显示在右边
55-
从最底层(游戏邦注:即第 4 个关卡)开始,创造第 3 个关卡有多种方法,但如果尝试所有可能性,你便会在创造第 1 个关卡前陷入困境
54+
<strong>解释:</strong>允许的三角形图案显示在右边
55+
从最底层(即第 4 )开始,创造第 3 层有多种方法,但如果尝试所有可能性,你便会在创造第 1 层前陷入困境
5656
</pre>
5757

5858
<p>&nbsp;</p>

0 commit comments

Comments
 (0)