Skip to content

Commit 5ded9f3

Browse files
authored
feat: update lc problems (doocs#4523)
1 parent 90f466e commit 5ded9f3

File tree

74 files changed

+358
-197
lines changed

Some content is hidden

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

74 files changed

+358
-197
lines changed

solution/0000-0099/0049.Group Anagrams/README.md

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,41 @@ tags:
1919

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

22-
<p>给你一个字符串数组,请你将 <strong>字母异位词</strong> 组合在一起。可以按任意顺序返回结果列表。</p>
23-
24-
<p><strong>字母异位词</strong> 是由重新排列源单词的所有字母得到的一个新单词。</p>
22+
<p>给你一个字符串数组,请你将 <span data-keyword="anagram">字母异位词</span> 组合在一起。可以按任意顺序返回结果列表。</p>
2523

2624
<p>&nbsp;</p>
2725

2826
<p><strong>示例 1:</strong></p>
2927

30-
<pre>
31-
<strong>输入:</strong> strs = <code>["eat", "tea", "tan", "ate", "nat", "bat"]</code>
32-
<strong>输出: </strong>[["bat"],["nat","tan"],["ate","eat","tea"]]</pre>
28+
<div class="example-block">
29+
<p><strong>输入:</strong> strs = ["eat", "tea", "tan", "ate", "nat", "bat"]</p>
30+
31+
<p><strong>输出: </strong>[["bat"],["nat","tan"],["ate","eat","tea"]]</p>
32+
33+
<p><strong>解释:</strong></p>
34+
35+
<ul>
36+
<li>在 strs 中没有字符串可以通过重新排列来形成 <code>"bat"</code>。</li>
37+
<li>字符串 <code>"nat"</code> 和 <code>"tan"</code> 是字母异位词,因为它们可以重新排列以形成彼此。</li>
38+
<li>字符串 <code>"ate"</code>&nbsp;,<code>"eat"</code>&nbsp;和 <code>"tea"</code> 是字母异位词,因为它们可以重新排列以形成彼此。</li>
39+
</ul>
40+
</div>
3341

3442
<p><strong>示例 2:</strong></p>
3543

36-
<pre>
37-
<strong>输入:</strong> strs = <code>[""]</code>
38-
<strong>输出: </strong>[[""]]
39-
</pre>
44+
<div class="example-block">
45+
<p><strong>输入:</strong> strs = [""]</p>
46+
47+
<p><strong>输出: </strong>[[""]]</p>
48+
</div>
4049

4150
<p><strong>示例 3:</strong></p>
4251

43-
<pre>
44-
<strong>输入:</strong> strs = <code>["a"]</code>
45-
<strong>输出: </strong>[["a"]]</pre>
52+
<div class="example-block">
53+
<p><strong>输入:</strong> strs = ["a"]</p>
54+
55+
<p><strong>输出: </strong>[["a"]]</p>
56+
</div>
4657

4758
<p>&nbsp;</p>
4859

solution/0000-0099/0066.Plus One/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,9 @@ tags:
1717

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

20-
<p>给定一个由 <strong>整数 </strong>组成的<strong> 非空</strong> 数组所表示的非负整数,在该数的基础上加一。</p>
20+
<p>给定一个表示 <strong>大整数</strong> 的整数数组 <code>digits</code>,其中 <code>digits[i]</code> 是整数的第 <code>i</code> 位数字。这些数字按从左到右,从最高位到最低位排列。这个大整数不包含任何前导 <code>0</code>。</p>
2121

22-
<p>最高位数字存放在数组的首位, 数组中每个元素只存储<strong>单个</strong>数字。</p>
23-
24-
<p>你可以假设除了整数 0 之外,这个整数不会以零开头。</p>
22+
<p>将大整数加 1,并返回结果的数字数组。</p>
2523

2624
<p>&nbsp;</p>
2725

@@ -31,6 +29,8 @@ tags:
3129
<strong>输入:</strong>digits = [1,2,3]
3230
<strong>输出:</strong>[1,2,4]
3331
<strong>解释:</strong>输入数组表示数字 123。
32+
加 1 后得到 123 + 1 = 124。
33+
因此,结果应该是 [1,2,4]。
3434
</pre>
3535

3636
<p><strong>示例&nbsp;2:</strong></p>
@@ -39,6 +39,8 @@ tags:
3939
<strong>输入:</strong>digits = [4,3,2,1]
4040
<strong>输出:</strong>[4,3,2,2]
4141
<strong>解释:</strong>输入数组表示数字 4321。
42+
加 1 后得到 4321 + 1 = 4322。
43+
因此,结果应该是 [4,3,2,2]。
4244
</pre>
4345

4446
<p><strong>示例 3:</strong></p>
@@ -58,6 +60,7 @@ tags:
5860
<ul>
5961
<li><code>1 &lt;= digits.length &lt;= 100</code></li>
6062
<li><code>0 &lt;= digits[i] &lt;= 9</code></li>
63+
<li><code>digits</code>&nbsp;不包含任何前导 <code>0</code>。</li>
6164
</ul>
6265

6366
<!-- description:end -->

solution/0200-0299/0228.Summary Ranges/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ tags:
1818

1919
<p>给定一个 &nbsp;<strong>无重复元素</strong> 的&nbsp;<strong>有序</strong> 整数数组 <code>nums</code> 。</p>
2020

21-
<p>返回 <em><strong>恰好覆盖数组中所有数字</strong> 的 <strong>最小有序</strong> 区间范围列表&nbsp;</em>。也就是说,<code>nums</code> 的每个元素都恰好被某个区间范围所覆盖,并且不存在属于某个范围但不属于 <code>nums</code> 的数字 <code>x</code> 。</p>
21+
<p>区间 <code>[a,b]</code> 是从 <code>a</code> 到 <code>b</code>(包含)的所有整数的集合。</p>
22+
23+
<p>返回 <em><strong>恰好覆盖数组中所有数字</strong> 的 <strong>最小有序</strong> 区间范围列表&nbsp;</em>。也就是说,<code>nums</code> 的每个元素都恰好被某个区间范围所覆盖,并且不存在属于某个区间但不属于 <code>nums</code> 的数字 <code>x</code> 。</p>
2224

2325
<p>列表中的每个区间范围 <code>[a,b]</code> 应该按如下格式输出:</p>
2426

solution/0200-0299/0250.Count Univalue Subtrees/README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,42 @@ tags:
1818

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

21-
<p>给定一个二叉树,统计该二叉树数值相同的<span data-keyword="subtree">子树</span>个数。</p>
21+
<p>给定一个二叉树,统计该二叉树数值相同的 <span data-keyword="subtree">子树</span> 个数。</p>
2222

2323
<p>同值子树是指该子树的所有节点都拥有相同的数值。</p>
2424

25-
<p><strong>示例:</strong></p>
25+
<p>&nbsp;</p>
2626

27+
<p><strong class="example">示例 1:</strong></p>
28+
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0250.Count%20Univalue%20Subtrees/images/unival_e1.jpg" style="width: 450px; height: 258px;" />
2729
<pre>
28-
<strong>输入: </strong>root = [5,1,5,5,5,null,5]
30+
<strong>输入:</strong>root = [5,1,5,5,5,null,5]
31+
<b>输出:</b>4
32+
</pre>
2933

30-
5
31-
/ \
32-
1 5
33-
/ \ \
34-
5 5 5
34+
<p><strong class="example">示例 2:</strong></p>
3535

36-
<strong>输出:</strong> 4
36+
<pre>
37+
<b>输入:</b>root = []
38+
<b>输出:</b>0
3739
</pre>
3840

41+
<p><strong class="example">示例 3:</strong></p>
42+
43+
<pre>
44+
<b>输入:</b>root = [5,5,5,5,5,null,5]
45+
<b>输出:</b>6
46+
</pre>
47+
48+
<p>&nbsp;</p>
49+
50+
<p><strong>提示:</strong></p>
51+
52+
<ul>
53+
<li>树中节点的编号在 <code>[0, 1000]</code>&nbsp;范围内</li>
54+
<li><code>-1000 &lt;= Node.val &lt;= 1000</code></li>
55+
</ul>
56+
3957
<!-- description:end -->
4058

4159
## 解法

solution/0300-0399/0328.Odd Even Linked List/README.md

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

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

19-
<p>给定单链表的头节点&nbsp;<code>head</code>&nbsp;将所有索引为奇数的节点和索引为偶数的节点分别组合在一起,然后返回重新排序的列表。</p>
19+
<p>给定单链表的头节点&nbsp;<code>head</code>&nbsp;将所有索引为奇数的节点和索引为偶数的节点分别分组,保持它们原有的相对顺序,然后把偶数索引节点分组连接到奇数索引节点分组之后,返回重新排序的链表。</p>
2020

2121
<p><strong>第一个</strong>节点的索引被认为是 <strong>奇数</strong> , <strong>第二个</strong>节点的索引为&nbsp;<strong>偶数</strong> ,以此类推。</p>
2222

solution/0400-0499/0412.Fizz Buzz/README.md

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

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

21-
<p>给你一个整数 <code>n</code> ,找出从 <code>1</code> 到 <code>n</code> 各个整数的 Fizz Buzz 表示,并用字符串数组 <code>answer</code>(<strong>下标从 1 开始</strong>)返回结果,其中:</p>
21+
<p>给你一个整数 <code>n</code> ,返回一个字符串数组 <code>answer</code>(<strong>下标从 1 开始</strong>),其中:</p>
2222

2323
<ul>
2424
<li><code>answer[i] == "FizzBuzz"</code> 如果 <code>i</code> 同时是 <code>3</code> 和 <code>5</code> 的倍数。</li>

solution/0400-0499/0418.Sentence Screen Fitting/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ bcd-e-
5454
<p><strong>示例 3:</strong></p>
5555

5656
<pre>
57-
<strong>输入:</strong>sentence = ["I", "had", "apple", "pie"], rows = 4, cols = 5
57+
<strong>输入:</strong>sentence = ["i", "had", "apple", "pie"], rows = 4, cols = 5
5858
<strong>输出:</strong>1
5959
<strong>解释:</strong>
60-
I-had
60+
i-had
6161
apple
62-
pie-I
62+
pie-i
6363
had--
6464
字符 '-' 表示屏幕上的一个空白位置。
6565
</pre>

solution/0500-0599/0520.Detect Capital/README.md

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

2121
<ul>
2222
<li>全部字母都是大写,比如 <code>"USA"</code> 。</li>
23-
<li>单词中所有字母都不是大写,比如 <code>"leetcode"</code> 。</li>
24-
<li>如果单词不只含有一个字母,只有首字母大写,&nbsp;比如&nbsp;<code>"Google"</code> 。</li>
23+
<li>所有字母都不是大写,比如 <code>"leetcode"</code> 。</li>
24+
<li>只有首字母大写,&nbsp;比如&nbsp;<code>"Google"</code> 。</li>
2525
</ul>
2626

2727
<p>给你一个字符串 <code>word</code> 。如果大写用法正确,返回 <code>true</code> ;否则,返回 <code>false</code> 。</p>

solution/0500-0599/0550.Game Play Analysis IV/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ tags:
3232
每一行是一个玩家的记录,他在某一天使用某个设备注销之前登录并玩了很多游戏(可能是 0)。
3333
</pre>
3434

35-
<p>&nbsp;</p>
36-
37-
<p>编写解决方案,报告在首次登录的第二天再次登录的玩家的 <strong>比率</strong>,<strong>四舍五入到小数点后两位</strong>。换句话说,你需要计算从首次登录日期开始至少连续两天登录的玩家的数量,然后除以玩家总数。</p>
35+
<p>编写解决方案,报告在首次登录的第二天再次登录的玩家的 <strong>比率</strong>,<strong>四舍五入到小数点后两位</strong>。换句话说,你需要计算从首次登录后的第二天登录的玩家数量,并将其除以总玩家数。</p>
3836

3937
<p>结果格式如下所示:</p>
4038

solution/0500-0599/0550.Game Play Analysis IV/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ This table shows the activity of players of some games.
3232
Each row is a record of a player who logged in and played a number of games (possibly 0) before logging out on someday using some device.
3333
</pre>
3434

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

37-
<p>Write a&nbsp;solution&nbsp;to report the <strong>fraction</strong> of players that logged in again on the day after the day they first logged in, <strong>rounded to 2 decimal places</strong>. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.</p>
37+
<p>Write a solution to report the <strong>fraction</strong> of players that logged in again on the day after the day they first logged in, <strong>rounded to 2 decimal places</strong>. In other words, you need to determine the number of players who logged in on the day immediately following their initial login, and divide it by the number of total players.</p>
3838

39-
<p>The&nbsp;result format is in the following example.</p>
39+
<p>The result format is in the following example.</p>
4040

4141
<p>&nbsp;</p>
4242
<p><strong class="example">Example 1:</strong></p>

0 commit comments

Comments
 (0)