Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c08d806

Browse files
authored
feat: update lc problems (doocs#3528)
1 parent 6ee014b commit c08d806

File tree

66 files changed

+2918
-53
lines changed

Some content is hidden

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

66 files changed

+2918
-53
lines changed

solution/0100-0199/0153.Find Minimum in Rotated Sorted Array/README_EN.md

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

2929
<p>Given the sorted rotated array <code>nums</code> of <strong>unique</strong> elements, return <em>the minimum element of this array</em>.</p>
3030

31-
<p>You must write an algorithm that runs in&nbsp;<code>O(log n) time.</code></p>
31+
<p>You must write an algorithm that runs in&nbsp;<code>O(log n) time</code>.</p>
3232

3333
<p>&nbsp;</p>
3434
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0345.Reverse Vowels of a String/README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,27 @@ tags:
2323

2424
<p>&nbsp;</p>
2525

26-
<p><strong>示例 1:</strong></p>
26+
<p><strong class="example">示例 1:</strong></p>
2727

28-
<pre>
29-
<strong>输入:</strong>s = "hello"
30-
<strong>输出:</strong>"holle"
31-
</pre>
28+
<div class="example-block">
29+
<p><strong>输入:</strong><span class="example-io">s = "IceCreAm"</span></p>
3230

33-
<p><strong>示例 2:</strong></p>
31+
<p><span class="example-io"><b>输出:</b>"AceCreIm"</span></p>
3432

35-
<pre>
36-
<strong>输入:</strong>s = "leetcode"
37-
<strong>输出:</strong>"leotcede"</pre>
33+
<p><strong>解释:</strong></p>
34+
35+
<p><code>s</code>&nbsp;中的元音是&nbsp;<code>['I', 'e', 'e', 'A']</code>。反转这些元音,<code>s</code> 变为&nbsp;<code>"AceCreIm"</code>.</p>
36+
</div>
37+
38+
<p><strong class="example">示例 2:</strong></p>
39+
40+
<div class="example-block">
41+
<p><span class="example-io"><b>输入:</b>s = "leetcode"</span></p>
42+
43+
<p><strong>输出:</strong><span class="example-io">"leotcede"</span></p>
3844

3945
<p>&nbsp;</p>
46+
</div>
4047

4148
<p><strong>提示:</strong></p>
4249

solution/0300-0399/0345.Reverse Vowels of a String/README_EN.md

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,25 @@ tags:
2323

2424
<p>&nbsp;</p>
2525
<p><strong class="example">Example 1:</strong></p>
26-
<pre><strong>Input:</strong> s = "hello"
27-
<strong>Output:</strong> "holle"
28-
</pre><p><strong class="example">Example 2:</strong></p>
29-
<pre><strong>Input:</strong> s = "leetcode"
30-
<strong>Output:</strong> "leotcede"
31-
</pre>
26+
27+
<div class="example-block">
28+
<p><strong>Input:</strong> <span class="example-io">s = &quot;IceCreAm&quot;</span></p>
29+
30+
<p><strong>Output:</strong> <span class="example-io">&quot;AceCreIm&quot;</span></p>
31+
32+
<p><strong>Explanation:</strong></p>
33+
34+
<p>The vowels in <code>s</code> are <code>[&#39;I&#39;, &#39;e&#39;, &#39;e&#39;, &#39;A&#39;]</code>. On reversing the vowels, s becomes <code>&quot;AceCreIm&quot;</code>.</p>
35+
</div>
36+
37+
<p><strong class="example">Example 2:</strong></p>
38+
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">s = &quot;leetcode&quot;</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">&quot;leotcede&quot;</span></p>
43+
</div>
44+
3245
<p>&nbsp;</p>
3346
<p><strong>Constraints:</strong></p>
3447

solution/0400-0499/0461.Hamming Distance/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ The above arrows point to positions where the corresponding bits are different.
4747
<li><code>0 &lt;=&nbsp;x, y &lt;= 2<sup>31</sup> - 1</code></li>
4848
</ul>
4949

50+
<p>&nbsp;</p>
51+
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/minimum-bit-flips-to-convert-number/description/" target="_blank"> 2220: Minimum Bit Flips to Convert Number.</a></p>
52+
5053
<!-- description:end -->
5154

5255
## Solutions

solution/1100-1199/1189.Maximum Number of Balloons/README.md

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,31 +20,34 @@ tags:
2020

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

23-
<p>给你一个字符串&nbsp;<code>text</code>,你需要使用 <code>text</code> 中的字母来拼凑尽可能多的单词&nbsp;<strong>&quot;balloon&quot;(气球)</strong>。</p>
23+
<p>给你一个字符串&nbsp;<code>text</code>,你需要使用 <code>text</code> 中的字母来拼凑尽可能多的单词&nbsp;<strong>"balloon"(气球)</strong>。</p>
2424

25-
<p>字符串&nbsp;<code>text</code> 中的每个字母最多只能被使用一次。请你返回最多可以拼凑出多少个单词&nbsp;<strong>&quot;balloon&quot;</strong>。</p>
25+
<p>字符串&nbsp;<code>text</code> 中的每个字母最多只能被使用一次。请你返回最多可以拼凑出多少个单词&nbsp;<strong>"balloon"</strong>。</p>
2626

2727
<p>&nbsp;</p>
2828

29-
<p><strong>示例 1:</strong></p>
29+
<p><strong class="example">示例 1:</strong></p>
3030

31-
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1189.Maximum%20Number%20of%20Balloons/images/1536_ex1_upd.jpeg" style="height: 35px; width: 154px;"></strong></p>
31+
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1189.Maximum%20Number%20of%20Balloons/images/1536_ex1_upd.jpeg" style="height: 35px; width: 154px;" /></strong></p>
3232

33-
<pre><strong>输入:</strong>text = &quot;nlaebolko&quot;
33+
<pre>
34+
<strong>输入:</strong>text = "nlaebolko"
3435
<strong>输出:</strong>1
3536
</pre>
3637

37-
<p><strong>示例 2:</strong></p>
38+
<p><strong class="example">示例 2:</strong></p>
3839

39-
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1189.Maximum%20Number%20of%20Balloons/images/1536_ex2_upd.jpeg" style="height: 35px; width: 233px;"></strong></p>
40+
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1100-1199/1189.Maximum%20Number%20of%20Balloons/images/1536_ex2_upd.jpeg" style="height: 35px; width: 233px;" /></strong></p>
4041

41-
<pre><strong>输入:</strong>text = &quot;loonbalxballpoon&quot;
42+
<pre>
43+
<strong>输入:</strong>text = "loonbalxballpoon"
4244
<strong>输出:</strong>2
4345
</pre>
4446

45-
<p><strong>示例 3:</strong></p>
47+
<p><strong class="example">示例 3:</strong></p>
4648

47-
<pre><strong>输入:</strong>text = &quot;leetcode&quot;
49+
<pre>
50+
<strong>输入:</strong>text = "leetcode"
4851
<strong>输出:</strong>0
4952
</pre>
5053

@@ -53,10 +56,14 @@ tags:
5356
<p><strong>提示:</strong></p>
5457

5558
<ul>
56-
<li><code>1 &lt;= text.length &lt;= 10^4</code></li>
59+
<li><code>1 &lt;= text.length &lt;= 10<sup>4</sup></code></li>
5760
<li><code>text</code>&nbsp;全部由小写英文字母组成</li>
5861
</ul>
5962

63+
<p>&nbsp;</p>
64+
65+
<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/rearrange-characters-to-make-target-string/">2287. 重排字符形成目标字符串</a>&nbsp;相同。</p>
66+
6067
<!-- description:end -->
6168

6269
## 解法

solution/1100-1199/1189.Maximum Number of Balloons/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ tags:
5858
<li><code>text</code> consists of lower case English letters only.</li>
5959
</ul>
6060

61+
<p>&nbsp;</p>
62+
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/rearrange-characters-to-make-target-string/description/" target="_blank"> 2287: Rearrange Characters to Make Target String.</a></p>
63+
6164
<!-- description:end -->
6265

6366
## Solutions

solution/1200-1299/1251.Average Selling Price/README.md

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

4949
<p>&nbsp;</p>
5050

51-
<p>编写解决方案以查找每种产品的平均售价。<code>average_price</code> 应该 <strong>四舍五入到小数点后两位</strong>。</p>
51+
<p>编写解决方案以查找每种产品的平均售价。<code>average_price</code> 应该 <strong>四舍五入到小数点后两位</strong>。如果产品没有任何售出,则假设其平均售价为 0。</p>
5252

5353
<p>返回结果表 <strong>无顺序要求</strong> 。</p>
5454

solution/1200-1299/1251.Average Selling Price/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Each row of this table indicates the date, units, and product_id of each product
5050

5151
<p>&nbsp;</p>
5252

53-
<p>Write a solution to find the average selling price for each product. <code>average_price</code> should be <strong>rounded to 2 decimal places</strong>.</p>
53+
<p>Write a solution to find the average selling price for each product. <code>average_price</code> should be <strong>rounded to 2 decimal places</strong>. If a product does not have any sold units, its average selling price is assumed to be 0.</p>
5454

5555
<p>Return the result table in <strong>any order</strong>.</p>
5656

solution/1600-1699/1683.Invalid Tweets/README_EN.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,21 @@ This table contains all the tweets in a social media app.
4343
<pre>
4444
<strong>Input:</strong>
4545
Tweets table:
46-
+----------+----------------------------------+
47-
| tweet_id | content |
48-
+----------+----------------------------------+
49-
| 1 | Vote for Biden |
50-
| 2 | Let us make America great again! |
51-
+----------+----------------------------------+
46+
+----------+-----------------------------------+
47+
| tweet_id | content |
48+
+----------+-----------------------------------+
49+
| 1 | Let us Code |
50+
| 2 | More than fifteen chars are here! |
51+
+----------+-----------------------------------+
5252
<strong>Output:</strong>
5353
+----------+
5454
| tweet_id |
5555
+----------+
5656
| 2 |
5757
+----------+
5858
<strong>Explanation:</strong>
59-
Tweet 1 has length = 14. It is a valid tweet.
60-
Tweet 2 has length = 32. It is an invalid tweet.
59+
Tweet 1 has length = 11. It is a valid tweet.
60+
Tweet 2 has length = 33. It is an invalid tweet.
6161
</pre>
6262

6363
<!-- description:end -->

solution/1700-1799/1743.Restore the Array From Adjacent Pairs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1700-1799/1743.Re
55
rating: 1579
66
source: 第 226 场周赛 Q2
77
tags:
8+
- 深度优先搜索
89
- 数组
910
- 哈希表
1011
---

solution/1700-1799/1743.Restore the Array From Adjacent Pairs/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1700-1799/1743.Re
55
rating: 1579
66
source: Weekly Contest 226 Q2
77
tags:
8+
- Depth-First Search
89
- Array
910
- Hash Table
1011
---

solution/1800-1899/1833.Maximum Ice Cream Bars/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: 第 237 场周赛 Q2
77
tags:
88
- 贪心
99
- 数组
10+
- 计数排序
1011
- 排序
1112
---
1213

solution/1800-1899/1833.Maximum Ice Cream Bars/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ source: Weekly Contest 237 Q2
77
tags:
88
- Greedy
99
- Array
10+
- Counting Sort
1011
- Sorting
1112
---
1213

solution/2200-2299/2220.Minimum Bit Flips to Convert Number/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ It can be shown we cannot convert 3 to 4 in less than 3 steps. Hence, we return
5757
<li><code>0 &lt;= start, goal &lt;= 10<sup>9</sup></code></li>
5858
</ul>
5959

60+
<p>&nbsp;</p>
61+
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/hamming-distance/description/" target="_blank">461: Hamming Distance.</a></p>
62+
6063
<!-- description:end -->
6164

6265
## Solutions

solution/2200-2299/2287.Rearrange Characters to Make Target String/README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ tags:
2828

2929
<p><strong>示例 1:</strong></p>
3030

31-
<pre><strong>输入:</strong>s = "ilovecodingonleetcode", target = "code"
31+
<pre>
32+
<strong>输入:</strong>s = "ilovecodingonleetcode", target = "code"
3233
<strong>输出:</strong>2
3334
<strong>解释:</strong>
3435
对于 "code" 的第 1 个副本,选取下标为 4 、5 、6 和 7 的字符。
@@ -39,7 +40,8 @@ tags:
3940

4041
<p><strong>示例 2:</strong></p>
4142

42-
<pre><strong>输入:</strong>s = "abcba", target = "abc"
43+
<pre>
44+
<strong>输入:</strong>s = "abcba", target = "abc"
4345
<strong>输出:</strong>1
4446
<strong>解释:</strong>
4547
选取下标为 0 、1 和 2 的字符,可以形成 "abc" 的 1 个副本。
@@ -49,7 +51,8 @@ tags:
4951

5052
<p><strong>示例 3:</strong></p>
5153

52-
<pre><strong>输入:</strong>s = "abbaccaddaeea", target = "aaaaa"
54+
<pre>
55+
<strong>输入:</strong>s = "abbaccaddaeea", target = "aaaaa"
5356
<strong>输出:</strong>1
5457
<strong>解释:</strong>
5558
选取下标为 0 、3 、6 、9 和 12 的字符,可以形成 "aaaaa" 的 1 个副本。
@@ -66,6 +69,10 @@ tags:
6669
<li><code>s</code> 和 <code>target</code> 由小写英文字母组成</li>
6770
</ul>
6871

72+
<p>&nbsp;</p>
73+
74+
<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/maximum-number-of-balloons/">1189. “气球” 的最大数量</a> 相同。</p>
75+
6976
<!-- description:end -->
7077

7178
## 解法

solution/2200-2299/2287.Rearrange Characters to Make Target String/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ We can make at most one copy of &quot;aaaaa&quot;, so we return 1.
6767
<li><code>s</code> and <code>target</code> consist of lowercase English letters.</li>
6868
</ul>
6969

70+
<p>&nbsp;</p>
71+
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/maximum-number-of-balloons/description/" target="_blank"> 1189: Maximum Number of Balloons.</a></p>
72+
7073
<!-- description:end -->
7174

7275
## Solutions

solution/2400-2499/2403.Minimum Time to Kill All Monsters/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tags:
4343
- Day 2: Gain 2 mana points to get a total of 2 mana points.
4444
- Day 3: Gain 2 mana points to get a total of 4 mana points. Spend all mana points to kill the 3<sup>rd</sup> monster.
4545
- Day 4: Gain 3 mana points to get a total of 3 mana points. Spend all mana points to kill the 1<sup>st</sup> monster.
46-
It can be proven that 4 is the minimum number of days needed.
46+
It can be proven that 4 is the minimum number of days needed.
4747
</pre>
4848

4949
<p><strong class="example">Example 2:</strong></p>
@@ -56,7 +56,7 @@ It can be proven that 4 is the minimum number of days needed.
5656
- Day 2: Gain 2 mana points to get a total of 2 mana points. Spend all mana points to kill the 2<sup>nd</sup> monster.
5757
- Day 3: Gain 3 mana points to get a total of 3 mana points.
5858
- Day 4: Gain 3 mana points to get a total of 6 mana points. Spend all mana points to kill the 3<sup>rd</sup> monster.
59-
It can be proven that 4 is the minimum number of days needed.
59+
It can be proven that 4 is the minimum number of days needed.
6060
</pre>
6161

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

solution/2600-2699/2631.Group By/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ tags:
1818

1919
<p>Write code that enhances all arrays such that you can call the&nbsp;<code>array.groupBy(fn)</code>&nbsp;method on any array and it will return a <strong>grouped</strong>&nbsp;version of the array.</p>
2020

21-
<p>A&nbsp;<strong>grouped</strong>&nbsp;array is an object where each&nbsp;key&nbsp;is&nbsp;the output of&nbsp;<code>fn(arr[i])</code>&nbsp;and each&nbsp;value is an array containing all items in the original array with that key.</p>
21+
<p>A <strong>grouped</strong> array is an object where each&nbsp;key&nbsp;is&nbsp;the output of <code>fn(arr[i])</code> and each value is an array containing all items in the original array which generate that key.</p>
2222

2323
<p>The provided callback&nbsp;<code>fn</code>&nbsp;will accept an item in the array and return a string key.</p>
2424

25-
<p>The order of each value list should be the order the items&nbsp;appear in the array. Any order of keys is acceptable.</p>
25+
<p>The order of each value list should be the order the items appear in the array. Any order of keys is acceptable.</p>
2626

2727
<p>Please solve it without lodash&#39;s&nbsp;<code>_.groupBy</code> function.</p>
2828

solution/2700-2799/2724.Sort By/README_EN.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>Given an array <code>arr</code> and a function <code>fn</code>, return a sorted array <code>sortedArr</code>. You can assume&nbsp;<code>fn</code>&nbsp;only returns numbers and those numbers determine the sort order of&nbsp;<code>sortedArr</code>. <code>sortedArray</code> must be sorted in <strong>ascending order</strong> by <code>fn</code> output.</p>
19+
<p>Given an array <code>arr</code> and a function <code>fn</code>, return a sorted array <code>sortedArr</code>. You can assume&nbsp;<code>fn</code>&nbsp;only returns numbers and those numbers determine the sort order of&nbsp;<code>sortedArr</code>. <code>sortedArr</code> must be sorted in <strong>ascending order</strong> by <code>fn</code> output.</p>
2020

2121
<p>You may assume that <code>fn</code> will never duplicate numbers for a given array.</p>
2222

solution/3000-3099/3038.Maximum Number of Operations With the Same Score I/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tags:
5151
<div class="example-block">
5252
<p><strong>Input:</strong> <span class="example-io">nums = [1,5,3,3,4,1,3,2,2,3]</span></p>
5353

54-
<p><strong>Output:</strong> <span class="example-io">1</span></p>
54+
<p><strong>Output:</strong> <span class="example-io">2</span></p>
5555

5656
<p><strong>Explanation:</strong></p>
5757

solution/3100-3199/3103.Find Trending Hashtags II/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929
+-------------+---------+
3030
tweet_id 是这张表的主键 (值互不相同的列)。
3131
这张表的每一行都包含 user_id, tweet_id, tweet_date 和 tweet。
32-
</pre>
32+
题目保证所有 tweet_date 都是 2024 年 2 月的合法日期。</pre>
3333

3434
<p>编写一个解决方案来找到&nbsp;<code>2024</code>&nbsp;年 <strong>二月&nbsp;</strong>的 <strong>前</strong>&nbsp;<code>3</code>&nbsp;热门话题 <strong>标签</strong>。一条推文可能含有 <strong>多个标签</strong>。</p>
3535

solution/3100-3199/3103.Find Trending Hashtags II/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ tags:
2929
+-------------+---------+
3030
tweet_id is the primary key (column with unique values) for this table.
3131
Each row of this table contains user_id, tweet_id, tweet_date and tweet.
32+
It is guaranteed that all tweet_date are valid dates in February 2024.
33+
3234
</pre>
3335

3436
<p>Write a solution to find the <strong>top</strong> <code>3</code> trending <strong>hashtags</strong> in <strong>February</strong> <code>2024</code>. Every tweet may contain <strong>several</strong> <strong>hashtags</strong>.</p>

0 commit comments

Comments
 (0)