Skip to content

Commit bfaf55b

Browse files
authored
feat: update lc problems (doocs#3419)
1 parent 162cdab commit bfaf55b

File tree

43 files changed

+545
-179
lines changed

Some content is hidden

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

43 files changed

+545
-179
lines changed

solution/0000-0099/0001.Two Sum/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ tags:
1919

2020
<p>给定一个整数数组 <code>nums</code>&nbsp;和一个整数目标值 <code>target</code>,请你在该数组中找出 <strong>和为目标值 </strong><em><code>target</code></em>&nbsp; 的那&nbsp;<strong>两个</strong>&nbsp;整数,并返回它们的数组下标。</p>
2121

22-
<p>你可以假设每种输入只会对应一个答案。但是,数组中同一个元素在答案里不能重复出现。</p>
22+
<p>你可以假设每种输入只会对应一个答案,并且你不能使用两次相同的元素。</p>
2323

2424
<p>你可以按任意顺序返回答案。</p>
2525

solution/0000-0099/0016.3Sum Closest/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ tags:
3131
<pre>
3232
<strong>输入:</strong>nums = [-1,2,1,-4], target = 1
3333
<strong>输出:</strong>2
34-
<strong>解释:</strong>与 target 最接近的和是 2 (-1 + 2 + 1 = 2)
34+
<strong>解释:</strong>与 target 最接近的和是 2 (-1 + 2 + 1 = 2)。
3535
</pre>
3636

3737
<p><strong>示例 2:</strong></p>
3838

3939
<pre>
4040
<strong>输入:</strong>nums = [0,0,0], target = 1
4141
<strong>输出:</strong>0
42-
</pre>
42+
<strong>解释:</strong>与 target 最接近的和是 0(0 + 0 + 0 = 0)。</pre>
4343

4444
<p>&nbsp;</p>
4545

solution/0000-0099/0071.Simplify Path/README.md

Lines changed: 57 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ tags:
1717

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

20-
<p>给你一个字符串 <code>path</code> ,表示指向某一文件或目录的 Unix 风格 <strong>绝对路径 </strong>(以 <code>'/'</code> 开头),请你将其转化为更加简洁的规范路径。</p>
20+
<p>给你一个字符串 <code>path</code> ,表示指向某一文件或目录的&nbsp;Unix 风格 <strong>绝对路径 </strong>(以 <code>'/'</code> 开头),请你将其转化为更加简洁的规范路径。</p>
2121

22-
<p class="MachineTrans-lang-zh-CN">在 Unix 风格的文件系统中,一个点(<code>.</code>)表示当前目录本身;此外,两个点 (<code>..</code>) 表示将目录切换到上一级(指向父目录);两者都可以是复杂相对路径的组成部分。任意多个连续的斜杠(即,<code>'//'</code>)都被视为单个斜杠 <code>'/'</code> 。 对于此问题,任何其他格式的点(例如,<code>'...'</code>)均被视为文件/目录名称。</p>
22+
<p class="MachineTrans-lang-zh-CN">在 Unix 风格的文件系统中,一个点(<code>.</code>)表示当前目录本身;此外,两个点 (<code>..</code>)&nbsp;表示将目录切换到上一级(指向父目录);两者都可以是复杂相对路径的组成部分。任意多个连续的斜杠(即,<code>'//'</code>)都被视为单个斜杠 <code>'/'</code> 。 对于此问题,任何其他格式的点(例如,<code>'...'</code>)均被视为文件/目录名称。</p>
2323

2424
<p>请注意,返回的 <strong>规范路径</strong> 必须遵循下述格式:</p>
2525

@@ -32,44 +32,74 @@ tags:
3232

3333
<p>返回简化后得到的 <strong>规范路径</strong> 。</p>
3434

35-
<p> </p>
35+
<p>&nbsp;</p>
3636

37-
<p><strong>示例 1:</strong></p>
37+
<p><strong class="example">示例 1:</strong></p>
3838

39-
<pre>
40-
<strong>输入:</strong>path = "/home/"
41-
<strong>输出:</strong>"/home"
42-
<strong>解释:</strong>注意,最后一个目录名后面没有斜杠。 </pre>
39+
<div class="example-block">
40+
<p><span class="example-io"><b>输入:</b>path = "/home/"</span></p>
4341

44-
<p><strong>示例 2:</strong></p>
42+
<p><span class="example-io"><b>输出:</b>"/home"</span></p>
4543

46-
<pre>
47-
<strong>输入:</strong>path = "/../"
48-
<strong>输出:</strong>"/"
49-
<strong>解释:</strong>从根目录向上一级是不可行的,因为根目录是你可以到达的最高级。
50-
</pre>
44+
<p><strong>解释:</strong></p>
5145

52-
<p><strong>示例 3:</strong></p>
46+
<p>应删除尾部斜杠。</p>
47+
</div>
5348

54-
<pre>
55-
<strong>输入:</strong>path = "/home//foo/"
56-
<strong>输出:</strong>"/home/foo"
57-
<strong>解释:</strong>在规范路径中,多个连续斜杠需要用一个斜杠替换。
58-
</pre>
49+
<p><strong class="example">示例 2:</strong></p>
5950

60-
<p><strong>示例 4:</strong></p>
51+
<div class="example-block">
52+
<p><span class="example-io"><b>输入:</b></span><span class="example-io">path = "/home//foo/"</span></p>
6153

62-
<pre>
63-
<strong>输入:</strong>path = "/a/./b/../../c/"
64-
<strong>输出:</strong>"/c"
65-
</pre>
54+
<p><span class="example-io"><b>输出:</b></span><span class="example-io">"/home/foo"</span></p>
6655

67-
<p> </p>
56+
<p><strong>解释:</strong></p>
57+
58+
<p>多个连续的斜杠被单个斜杠替换。</p>
59+
</div>
60+
61+
<p><strong class="example">示例 3:</strong></p>
62+
63+
<div class="example-block">
64+
<p><span class="example-io"><b>输入:</b></span><span class="example-io">path = "/home/user/Documents/../Pictures"</span></p>
65+
66+
<p><span class="example-io"><b>输出:</b></span><span class="example-io">"/home/user/Pictures"</span></p>
67+
68+
<p><strong>解释:</strong></p>
69+
70+
<p>两个点&nbsp;<code>".."</code>&nbsp;表示上一级目录。</p>
71+
</div>
72+
73+
<p><strong class="example">示例 4:</strong></p>
74+
75+
<div class="example-block">
76+
<p><span class="example-io"><b>输入:</b></span><span class="example-io">path = "/../"</span></p>
77+
78+
<p><span class="example-io"><b>输出:</b></span><span class="example-io">"/"</span></p>
79+
80+
<p><strong>解释:</strong></p>
81+
82+
<p>不可能从根目录上升级一级。</p>
83+
</div>
84+
85+
<p><strong class="example">示例 5:</strong></p>
86+
87+
<div class="example-block">
88+
<p><span class="example-io"><b>输入:</b></span><span class="example-io">path = "/.../a/../b/c/../d/./"</span></p>
89+
90+
<p><span class="example-io"><b>输出:</b></span><span class="example-io">"/.../b/d"</span></p>
91+
92+
<p><strong>解释:</strong></p>
93+
94+
<p><code>"..."</code> 是此问题中目录的有效名称。</p>
95+
</div>
96+
97+
<p>&nbsp;</p>
6898

6999
<p><strong>提示:</strong></p>
70100

71101
<ul>
72-
<li><code>1 <= path.length <= 3000</code></li>
102+
<li><code>1 &lt;= path.length &lt;= 3000</code></li>
73103
<li><code>path</code> 由英文字母,数字,<code>'.'</code>,<code>'/'</code> 或 <code>'_'</code> 组成。</li>
74104
<li><code>path</code> 是一个有效的 Unix 风格绝对路径。</li>
75105
</ul>

solution/0200-0299/0230.Kth Smallest Element in a BST/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tags:
1111

1212
<!-- problem:start -->
1313

14-
# [230. 二叉搜索树中第K小的元素](https://leetcode.cn/problems/kth-smallest-element-in-a-bst)
14+
# [230. 二叉搜索树中第 K 小的元素](https://leetcode.cn/problems/kth-smallest-element-in-a-bst)
1515

1616
[English Version](/solution/0200-0299/0230.Kth%20Smallest%20Element%20in%20a%20BST/README_EN.md)
1717

solution/0300-0399/0308.Range Sum Query 2D - Mutable/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ tags:
1212

1313
<!-- problem:start -->
1414

15-
# [308. 二维区域和检索 - 可变 🔒](https://leetcode.cn/problems/range-sum-query-2d-mutable)
15+
# [308. 二维区域和检索 - 矩阵可修改 🔒](https://leetcode.cn/problems/range-sum-query-2d-mutable)
1616

1717
[English Version](/solution/0300-0399/0308.Range%20Sum%20Query%202D%20-%20Mutable/README_EN.md)
1818

solution/0400-0499/0457.Circular Array Loop/README.md

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,29 +39,33 @@ tags:
3939

4040
<p>&nbsp;</p>
4141

42-
<p><strong>示例 1:</strong></p>
43-
42+
<p><strong class="example">示例 1:</strong></p>
43+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0457.Circular%20Array%20Loop/images/1723688159-qYjpWT-image.png" style="width: 402px; height: 289px;" />
4444
<pre>
4545
<strong>输入:</strong>nums = [2,-1,1,2,2]
4646
<strong>输出:</strong>true
47-
<strong>解释:</strong>存在循环,按下标 0 -&gt; 2 -&gt; 3 -&gt; 0 。循环长度为 3 。
47+
<strong>解释:</strong>图片展示了节点间如何连接。白色节点向前跳跃,而红色节点向后跳跃。
48+
我们可以看到存在循环,按下标 0 -&gt; 2 -&gt; 3 -&gt; 0 --&gt; ...,并且其中的所有节点都是白色(以相同方向跳跃)。
4849
</pre>
4950

50-
<p><strong>示例 2:</strong></p>
51-
51+
<p><strong class="example">示例 2:</strong></p>
52+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0457.Circular%20Array%20Loop/images/1723688183-lRSkjp-image.png" style="width: 402px; height: 390px;" />
5253
<pre>
53-
<strong>输入:</strong>nums = [-1,2]
54+
<strong>输入:</strong>nums = [-1,-2,-3,-4,-5,6]
5455
<strong>输出:</strong>false
55-
<strong>解释:</strong>按下标 1 -&gt; 1 -&gt; 1 ... 的运动无法构成循环,因为循环的长度为 1 。根据定义,循环的长度必须大于 1 。
56+
<strong>解释:</strong>图片展示了节点间如何连接。白色节点向前跳跃,而红色节点向后跳跃。
57+
唯一的循环长度为 1,所以返回 false。
5658
</pre>
5759

58-
<p><strong>示例 3:</strong></p>
59-
60+
<p><strong class="example">示例 3</strong></p>
61+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0457.Circular%20Array%20Loop/images/1723688199-nhaMuF-image.png" style="width: 497px; height: 242px;" />
6062
<pre>
61-
<strong>输入:</strong>nums = [-2,1,-1,-2,-2]
62-
<strong>输出:</strong>false
63-
<strong>解释:</strong>按下标 1 -&gt; 2 -&gt; 1 -&gt; ... 的运动无法构成循环,因为 nums[1] 是正数,而 nums[2] 是负数。
64-
所有 nums[seq[j]] 应当不是全正就是全负。</pre>
63+
<strong>输入:</strong>nums = [1,-1,5,1,4]
64+
<strong>输出:</strong>true
65+
<strong>解释:</strong>图片展示了节点间如何连接。白色节点向前跳跃,而红色节点向后跳跃。
66+
我们可以看到存在循环,按下标 0 --&gt; 1 --&gt; 0 --&gt; ...,当它的大小大于 1 时,它有一个向前跳的节点和一个向后跳的节点,所以 <strong>它不是一个循环</strong>。
67+
我们可以看到存在循环,按下标 3 --&gt; 4 --&gt; 3 --&gt; ...,并且其中的所有节点都是白色(以相同方向跳跃)。
68+
</pre>
6569

6670
<p>&nbsp;</p>
6771

Loading
Loading
Loading

solution/0600-0699/0638.Shopping Offers/README.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929

3030
<p>返回<strong> 确切 </strong>满足购物清单所需花费的最低价格,你可以充分利用大礼包的优惠活动。你不能购买超出购物清单指定数量的物品,即使那样会降低整体价格。任意大礼包可无限次购买。</p>
3131

32-
<p> </p>
32+
<p>&nbsp;</p>
3333

3434
<p><strong>示例 1:</strong></p>
3535

@@ -51,19 +51,18 @@ tags:
5151
需要买 1A ,2B 和 1C ,所以付 ¥4 买 1A 和 1B(大礼包 1),以及 ¥3 购买 1B , ¥4 购买 1C 。
5252
不可以购买超出待购清单的物品,尽管购买大礼包 2 更加便宜。</pre>
5353

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

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

5858
<ul>
59-
<li><code>n == price.length</code></li>
60-
<li><code>n == needs.length</code></li>
61-
<li><code>1 <= n <= 6</code></li>
62-
<li><code>0 <= price[i] <= 10</code></li>
63-
<li><code>0 <= needs[i] <= 10</code></li>
64-
<li><code>1 <= special.length <= 100</code></li>
59+
<li><code>n == price.length == needs.length</code></li>
60+
<li><code>1 &lt;= n &lt;= 6</code></li>
61+
<li><code>0 &lt;= price[i], needs[i] &lt;= 10</code></li>
62+
<li><code>1 &lt;= special.length &lt;= 100</code></li>
6563
<li><code>special[i].length == n + 1</code></li>
66-
<li><code>0 <= special[i][j] <= 50</code></li>
64+
<li><code>0 &lt;= special[i][j] &lt;= 50</code></li>
65+
<li>生成的输入对于&nbsp;<code>0 &lt;= j &lt;= n - 1</code> 至少有一个&nbsp;<code>special[i][j]</code>&nbsp;非零。</li>
6766
</ul>
6867

6968
<!-- description:end -->

0 commit comments

Comments
 (0)