Skip to content

Commit 93dfaca

Browse files
authored
feat: update lc problems (#4123)
1 parent e8ccff4 commit 93dfaca

File tree

32 files changed

+520
-53
lines changed

32 files changed

+520
-53
lines changed

solution/0200-0299/0262.Trips and Users/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ banned 是一个表示用户是否被禁止的枚举类型,枚举成员为 (
6161

6262
<p><strong>取消率</strong> 的计算方式如下:(被司机或乘客取消的非禁止用户生成的订单数量) / (非禁止用户生成的订单总数)。</p>
6363

64-
<p>编写解决方案找出&nbsp;<code>"2013-10-01"</code><strong>&nbsp;</strong>至&nbsp;<code>"2013-10-03"</code><strong>&nbsp;</strong>期间非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的取消率。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>
64+
<p>编写解决方案找出&nbsp;<code>"2013-10-01"</code><strong>&nbsp;</strong>至&nbsp;<code>"2013-10-03"</code><strong>&nbsp;</strong>期间有&nbsp;<strong>至少&nbsp;</strong>一次行程的非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的 <strong>取消率</strong>。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>
6565

6666
<p>返回结果表中的数据 <strong>无顺序要求</strong> 。</p>
6767

solution/1300-1399/1363.Largest Multiple of Three/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ source: 第 177 场周赛 Q4
77
tags:
88
- 贪心
99
- 数组
10+
- 数学
1011
- 动态规划
12+
- 排序
1113
---
1214

1315
<!-- problem:start -->

solution/1300-1399/1363.Largest Multiple of Three/README_EN.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ source: Weekly Contest 177 Q4
77
tags:
88
- Greedy
99
- Array
10+
- Math
1011
- Dynamic Programming
12+
- Sorting
1113
---
1214

1315
<!-- problem:start -->

solution/1300-1399/1365.How Many Numbers Are Smaller Than the Current Number/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source: 第 178 场周赛 Q1
77
tags:
88
- 数组
99
- 哈希表
10-
- 计数
10+
- 计数排序
1111
- 排序
1212
---
1313

solution/1300-1399/1365.How Many Numbers Are Smaller Than the Current Number/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ source: Weekly Contest 178 Q1
77
tags:
88
- Array
99
- Hash Table
10-
- Counting
10+
- Counting Sort
1111
- Sorting
1212
---
1313

solution/1400-1499/1434.Number of Ways to Wear Different Hats to Each Other/README.md

-7
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ tags:
5757
(1,2,3,4) 4 个帽子的排列方案数为 24 。
5858
</pre>
5959

60-
<p><strong>示例 4:</strong></p>
61-
62-
<pre>
63-
<strong>输入:</strong>hats = [[1,2,3],[2,3,5,6],[1,3,7,9],[1,8,9],[2,5,7]]
64-
<strong>输出:</strong>111
65-
</pre>
66-
6760
<p>&nbsp;</p>
6861

6962
<p><strong>提示:</strong></p>

solution/1400-1499/1434.Number of Ways to Wear Different Hats to Each Other/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tags:
2525

2626
<p>Given a 2D integer array <code>hats</code>, where <code>hats[i]</code> is a list of all hats preferred by the <code>i<sup>th</sup></code> person.</p>
2727

28-
<p>Return <em>the number of ways that the <code>n</code> people wear different hats to each other</em>.</p>
28+
<p>Return the number of ways that <code>n</code> people can wear <strong>different</strong> hats from each other.</p>
2929

3030
<p>Since the answer may be too large, return it modulo <code>10<sup>9</sup> + 7</code>.</p>
3131

solution/1900-1999/1968.Array With Elements Not Equal to Average of Neighbors/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ When i=3, nums[i] = 5, and the average of its neighbors is (4+3) / 2 = 3.5.
4747
When i=1, nums[i] = 7, and the average of its neighbors is (9+6) / 2 = 7.5.
4848
When i=2, nums[i] = 6, and the average of its neighbors is (7+2) / 2 = 4.5.
4949
When i=3, nums[i] = 2, and the average of its neighbors is (6+0) / 2 = 3.
50-
</pre>
50+
Note that the original array [6,2,0,9,7] also satisfies the conditions.</pre>
5151

5252
<p>&nbsp;</p>
5353
<p><strong>Constraints:</strong></p>

solution/1900-1999/1974.Minimum Time to Type Word Using Special Typewriter/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ tags:
3636
<pre>
3737
<strong>Input:</strong> word = &quot;abc&quot;
3838
<strong>Output:</strong> 5
39-
<strong>Explanation:
39+
<strong>Explanation:
4040
</strong>The characters are printed as follows:
4141
- Type the character &#39;a&#39; in 1 second since the pointer is initially on &#39;a&#39;.
4242
- Move the pointer clockwise to &#39;b&#39; in 1 second.

solution/2100-2199/2138.Divide a String Into Groups of Size k/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tags:
2222
<p>A string <code>s</code> can be partitioned into groups of size <code>k</code> using the following procedure:</p>
2323

2424
<ul>
25-
<li>The first group consists of the first <code>k</code> characters of the string, the second group consists of the next <code>k</code> characters of the string, and so on. Each character can be a part of <strong>exactly one</strong> group.</li>
25+
<li>The first group consists of the first <code>k</code> characters of the string, the second group consists of the next <code>k</code> characters of the string, and so on. Each element can be a part of <strong>exactly one</strong> group.</li>
2626
<li>For the last group, if the string <strong>does not</strong> have <code>k</code> characters remaining, a character <code>fill</code> is used to complete the group.</li>
2727
</ul>
2828

solution/2200-2299/2276.Count Integers in Intervals/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ tags:
4848
[null, null, null, 6, null, 8]
4949

5050
<strong>Explanation</strong>
51-
CountIntervals countIntervals = new CountIntervals(); // initialize the object with an empty set of intervals.
51+
CountIntervals countIntervals = new CountIntervals(); // initialize the object with an empty set of intervals.
5252
countIntervals.add(2, 3); // add [2, 3] to the set of intervals.
5353
countIntervals.add(7, 10); // add [7, 10] to the set of intervals.
5454
countIntervals.count(); // return 6

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tags:
4444
<strong>输入:</strong>s = "abcba", target = "abc"
4545
<strong>输出:</strong>1
4646
<strong>解释:</strong>
47-
选取下标为 0 、1 和 2 的字符,可以形成 "abc" 的 1 个副本。
47+
选取下标为 0 、1 和 2 的字符,可以形成 "abc" 的 1 个副本。
4848
可以形成最多 1 个 "abc" 的副本,所以返回 1 。
4949
注意,尽管下标 3 和 4 分别有额外的 'a' 和 'b' ,但不能重用下标 2 处的 'c' ,所以无法形成 "abc" 的第 2 个副本。
5050
</pre>

solution/2200-2299/2296.Design a Text Editor/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ textEditor.deleteText(4); // 返回 4
6262
// 删除了 4 个字符。
6363
textEditor.addText("practice"); // 当前文本为 "leetpractice|" 。
6464
textEditor.cursorRight(3); // 返回 "etpractice"
65-
// 当前文本为 "leetpractice|".
65+
// 当前文本为 "leetpractice|".
6666
// 光标无法移动到文本以外,所以无法移动。
6767
// "etpractice" 是光标左边的 10 个字符。
6868
textEditor.cursorLeft(8); // 返回 "leet"

solution/2200-2299/2296.Design a Text Editor/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ tags:
5757
TextEditor textEditor = new TextEditor(); // The current text is &quot;|&quot;. (The &#39;|&#39; character represents the cursor)
5858
textEditor.addText(&quot;leetcode&quot;); // The current text is &quot;leetcode|&quot;.
5959
textEditor.deleteText(4); // return 4
60-
// The current text is &quot;leet|&quot;.
60+
// The current text is &quot;leet|&quot;.
6161
// 4 characters were deleted.
62-
textEditor.addText(&quot;practice&quot;); // The current text is &quot;leetpractice|&quot;.
62+
textEditor.addText(&quot;practice&quot;); // The current text is &quot;leetpractice|&quot;.
6363
textEditor.cursorRight(3); // return &quot;etpractice&quot;
64-
// The current text is &quot;leetpractice|&quot;.
64+
// The current text is &quot;leetpractice|&quot;.
6565
// The cursor cannot be moved beyond the actual text and thus did not move.
6666
// &quot;etpractice&quot; is the last 10 characters to the left of the cursor.
6767
textEditor.cursorLeft(8); // return &quot;leet&quot;
@@ -72,7 +72,7 @@ textEditor.deleteText(10); // return 4
7272
// Only 4 characters were deleted.
7373
textEditor.cursorLeft(2); // return &quot;&quot;
7474
// The current text is &quot;|practice&quot;.
75-
// The cursor cannot be moved beyond the actual text and thus did not move.
75+
// The cursor cannot be moved beyond the actual text and thus did not move.
7676
// &quot;&quot; is the last min(10, 0) = 0 characters to the left of the cursor.
7777
textEditor.cursorRight(6); // return &quot;practi&quot;
7878
// The current text is &quot;practi|ce&quot;.

solution/2300-2399/2319.Check if Matrix Is X-Matrix/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ tags:
3434
<pre>
3535
<strong>Input:</strong> grid = [[2,0,0,1],[0,3,1,0],[0,5,2,0],[4,0,0,2]]
3636
<strong>Output:</strong> true
37-
<strong>Explanation:</strong> Refer to the diagram above.
37+
<strong>Explanation:</strong> Refer to the diagram above.
3838
An X-Matrix should have the green elements (diagonals) be non-zero and the red elements be 0.
3939
Thus, grid is an X-Matrix.
4040
</pre>

solution/2300-2399/2320.Count Number of Ways to Place Houses/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ tags:
3030
<pre>
3131
<strong>Input:</strong> n = 1
3232
<strong>Output:</strong> 4
33-
<strong>Explanation:</strong>
33+
<strong>Explanation:</strong>
3434
Possible arrangements:
3535
1. All plots are empty.
3636
2. A house is placed on one side of the street.

solution/2500-2599/2562.Find the Array Concatenation Value/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ tags:
3131
<p><code>nums</code>&nbsp;的 <strong>串联值</strong>&nbsp;最初等于 <code>0</code> 。执行下述操作直到&nbsp;<code>nums</code>&nbsp;变为空:</p>
3232

3333
<ul>
34-
<li>如果&nbsp;<code>nums</code>&nbsp;中存在不止一个数字,分别选中 <code>nums</code> 中的第一个元素和最后一个元素,将二者串联得到的值加到&nbsp;<code>nums</code>&nbsp;的 <strong>串联值</strong> 上,然后从&nbsp;<code>nums</code>&nbsp;中删除第一个和最后一个元素。</li>
35-
<li>如果仅存在一个元素,则将该元素的值加到&nbsp;<code>nums</code> 的串联值上,然后删除这个元素。</li>
34+
<li>如果&nbsp;<code>nums</code>&nbsp;的长度大于 1,分别选中 <code>nums</code> 中的第一个元素和最后一个元素,将二者串联得到的值加到&nbsp;<code>nums</code>&nbsp;的 <strong>串联值</strong> 上,然后从&nbsp;<code>nums</code>&nbsp;中删除第一个和最后一个元素。例如,如果&nbsp;<code>nums</code> 是 <code>[1, 2, 4, 5, 6]</code>,将 16 添加到串联值。</li>
35+
<li>如果&nbsp;<code>nums</code>&nbsp;中仅存在一个元素,则将该元素的值加到&nbsp;<code>nums</code> 的串联值上,然后删除这个元素。</li>
3636
</ul>
3737

3838
<p>返回执行完所有操作后<em>&nbsp;</em><code>nums</code> 的串联值。</p>

solution/2500-2599/2562.Find the Array Concatenation Value/README_EN.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ tags:
3131
<p>The <strong>concatenation value</strong> of <code>nums</code> is initially equal to <code>0</code>. Perform this operation until <code>nums</code> becomes empty:</p>
3232

3333
<ul>
34-
<li>If there exists more than one number in <code>nums</code>, pick the first element and last element in <code>nums</code> respectively and add the value of their concatenation to the <strong>concatenation value</strong> of <code>nums</code>, then delete the first and last element from <code>nums</code>.</li>
35-
<li>If one element exists, add its value to the <strong>concatenation value</strong> of <code>nums</code>, then delete it.</li>
34+
<li>If <code>nums</code> has a size greater than one, add the value of the concatenation of the first and the last element to the <strong>concatenation value</strong> of <code>nums</code>, and remove those two elements from <code>nums</code>. For example, if the <code>nums</code> was <code>[1, 2, 4, 5, 6]</code>, add 16 to the <code>concatenation value</code>.</li>
35+
<li>If only one element exists in <code>nums</code>, add its value to the <strong>concatenation value</strong> of <code>nums</code>, then remove it.</li>
3636
</ul>
3737

38-
<p>Return<em> the concatenation value of the <code>nums</code></em>.</p>
38+
<p>Return<em> the concatenation value of <code>nums</code></em>.</p>
3939

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

solution/2500-2599/2574.Left and Right Sum Differences/README.md

+7-10
Original file line numberDiff line numberDiff line change
@@ -19,35 +19,32 @@ tags:
1919

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

22-
<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,请你找出一个下标从 <strong>0</strong> 开始的整数数组 <code>answer</code> ,其中:</p>
22+
<p>给你一个下标从 <strong>0</strong> 开始的长度为&nbsp;<code>n</code>&nbsp;的整数数组 <code>nums</code></p>
2323

24-
<ul>
25-
<li><code>answer.length == nums.length</code></li>
26-
<li><code>answer[i] = |leftSum[i] - rightSum[i]|</code></li>
27-
</ul>
28-
29-
<p>其中:</p>
24+
<p>定义两个数组&nbsp;<code>leftSum</code>&nbsp;&nbsp;<code>rightSum</code>,其中:</p>
3025

3126
<ul>
3227
<li><code>leftSum[i]</code> 是数组 <code>nums</code> 中下标 <code>i</code> 左侧元素之和。如果不存在对应的元素,<code>leftSum[i] = 0</code> 。</li>
3328
<li><code>rightSum[i]</code> 是数组 <code>nums</code> 中下标 <code>i</code> 右侧元素之和。如果不存在对应的元素,<code>rightSum[i] = 0</code> 。</li>
3429
</ul>
3530

36-
<p>返回数组 <code>answer</code> 。</p>
31+
<p>返回长度为&nbsp;<code>n</code> 数组 <code>answer</code>,其中 <code>answer[i] = |leftSum[i] - rightSum[i]|</code>。</p>
3732

3833
<p>&nbsp;</p>
3934

4035
<p><strong>示例 1:</strong></p>
4136

42-
<pre><strong>输入:</strong>nums = [10,4,8,3]
37+
<pre>
38+
<strong>输入:</strong>nums = [10,4,8,3]
4339
<strong>输出:</strong>[15,1,11,22]
4440
<strong>解释:</strong>数组 leftSum 为 [0,10,14,22] 且数组 rightSum 为 [15,11,3,0] 。
4541
数组 answer 为 [|0 - 15|,|10 - 11|,|14 - 3|,|22 - 0|] = [15,1,11,22] 。
4642
</pre>
4743

4844
<p><strong>示例 2:</strong></p>
4945

50-
<pre><strong>输入:</strong>nums = [1]
46+
<pre>
47+
<strong>输入:</strong>nums = [1]
5148
<strong>输出:</strong>[0]
5249
<strong>解释:</strong>数组 leftSum 为 [0] 且数组 rightSum 为 [0] 。
5350
数组 answer 为 [|0 - 0|] = [0] 。

solution/2500-2599/2574.Left and Right Sum Differences/README_EN.md

+5-10
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,16 @@ tags:
1919

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

22-
<p>Given a <strong>0-indexed</strong> integer array <code>nums</code>, find a <strong>0-indexed </strong>integer array <code>answer</code> where:</p>
22+
<p>You are given a <strong>0-indexed</strong> integer array <code>nums</code> of size <code>n</code>.</p>
2323

24-
<ul>
25-
<li><code>answer.length == nums.length</code>.</li>
26-
<li><code>answer[i] = |leftSum[i] - rightSum[i]|</code>.</li>
27-
</ul>
28-
29-
<p>Where:</p>
24+
<p>Define two arrays <code>leftSum</code> and <code>rightSum</code> where:</p>
3025

3126
<ul>
32-
<li><code>leftSum[i]</code> is the sum of elements to the left of the index <code>i</code> in the array <code>nums</code>. If there is no such element, <code>leftSum[i] = 0</code>.</li>
33-
<li><code>rightSum[i]</code> is the sum of elements to the right of the index <code>i</code> in the array <code>nums</code>. If there is no such element, <code>rightSum[i] = 0</code>.</li>
27+
<li><code>leftSum[i]</code> is the sum of elements to the left of the index <code>i</code> in the array <code>nums</code>. If there is no such element, <code>leftSum[i] = 0</code>.</li>
28+
<li><code>rightSum[i]</code> is the sum of elements to the right of the index <code>i</code> in the array <code>nums</code>. If there is no such element, <code>rightSum[i] = 0</code>.</li>
3429
</ul>
3530

36-
<p>Return <em>the array</em> <code>answer</code>.</p>
31+
<p>Return an integer array <code>answer</code> of size <code>n</code> where <code>answer[i] = |leftSum[i] - rightSum[i]|</code>.</p>
3732

3833
<p>&nbsp;</p>
3934
<p><strong class="example">Example 1:</strong></p>

solution/3100-3199/3147.Taking Maximum Energy From the Mystic Dungeon/README_EN.md

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ tags:
2727

2828
<p>You are given an array <code>energy</code> and an integer <code>k</code>. Return the <strong>maximum</strong> possible energy you can gain.</p>
2929

30+
<p><strong>Note</strong> that when you are reach a magician, you <em>must</em> take energy from them, whether it is negative or positive energy.</p>
31+
3032
<p>&nbsp;</p>
3133
<p><strong class="example">Example 1:</strong></p>
3234

0 commit comments

Comments
 (0)