Skip to content

Commit 6c6cb55

Browse files
authored
feat: update lc problems (doocs#4255)
1 parent 4d8038c commit 6c6cb55

File tree

45 files changed

+14395
-14297
lines changed

Some content is hidden

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

45 files changed

+14395
-14297
lines changed

solution/0100-0199/0131.Palindrome Partitioning/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>s</code>,请你将<em> </em><code>s</code><em> </em>分割成一些子串,使每个子串都是 <strong><span data-keyword="palindrome-string">回文串</span></strong> 。返回 <code>s</code> 所有可能的分割方案。</p>
21+
<p>给你一个字符串 <code>s</code>,请你将<em> </em><code>s</code><em> </em>分割成一些 <span data-keyword="substring-nonempty">子串</span>,使每个子串都是 <strong><span data-keyword="palindrome-string">回文串</span></strong> 。返回 <code>s</code> 所有可能的分割方案。</p>
2222

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

solution/0500-0599/0525.Contiguous Array/README.md

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

2121
<p>给定一个二进制数组 <code>nums</code> , 找到含有相同数量的 <code>0</code> 和 <code>1</code> 的最长连续子数组,并返回该子数组的长度。</p>
2222

23-
<p> </p>
23+
<p>&nbsp;</p>
2424

25-
<p><strong>示例 1:</strong></p>
25+
<p><strong>示例 1</strong></p>
2626

2727
<pre>
28-
<strong>输入:</strong> nums = [0,1]
29-
<strong>输出:</strong> 2
30-
<strong>说明:</strong> [0, 1] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
28+
<strong>输入</strong>nums = [0,1]
29+
<strong>输出</strong>2
30+
<strong>说明</strong>[0, 1] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
3131

32-
<p><strong>示例 2:</strong></p>
32+
<p><strong>示例 2</strong></p>
3333

3434
<pre>
35-
<strong>输入:</strong> nums = [0,1,0]
36-
<strong>输出:</strong> 2
37-
<strong>说明:</strong> [0, 1] (或 [1, 0]) 是具有相同数量0和1的最长连续子数组。</pre>
35+
<strong>输入</strong>nums = [0,1,0]
36+
<strong>输出</strong>2
37+
<strong>说明</strong>[0, 1] (或 [1, 0]) 是具有相同数量 0 和 1 的最长连续子数组。</pre>
3838

39-
<p> </p>
39+
<p><strong>示例 3:</strong></p>
40+
41+
<pre>
42+
<b>输入:</b>nums = [0,1,1,1,1,1,0,0,0]
43+
<b>输出:</b>6
44+
<b>解释:</b>[1,1,1,0,0,0] 是具有相同数量 0 和 1 的最长连续子数组。</pre>
45+
46+
<p>&nbsp;</p>
4047

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

4350
<ul>
44-
<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>
51+
<li><code>1 &lt;= nums.length &lt;= 10<sup>5</sup></code></li>
4552
<li><code>nums[i]</code> 不是 <code>0</code> 就是 <code>1</code></li>
4653
</ul>
4754

solution/0500-0599/0525.Contiguous Array/README_EN.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ tags:
3737
<strong>Explanation:</strong> [0, 1] (or [1, 0]) is a longest contiguous subarray with equal number of 0 and 1.
3838
</pre>
3939

40+
<p><strong class="example">Example 3:</strong></p>
41+
42+
<pre>
43+
<strong>Input:</strong> nums = [0,1,1,1,1,1,0,0,0]
44+
<strong>Output:</strong> 6
45+
<strong>Explanation:</strong> [1,1,1,0,0,0] is the longest contiguous subarray with equal number of 0 and 1.
46+
</pre>
47+
4048
<p>&nbsp;</p>
4149
<p><strong>Constraints:</strong></p>
4250

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

Lines changed: 0 additions & 7 deletions
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

Lines changed: 1 addition & 1 deletion
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/1400-1499/1471.The k Strongest Values in an Array/README.md

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -35,52 +35,44 @@ tags:
3535

3636
<ul>
3737
<li>例如 <code>arr =&nbsp;[6, -3, 7, 2, 11]</code>,<code>n = 5</code>:数组排序后得到 <code>arr = [-3, 2, 6, 7, 11]</code> ,数组的中间位置为 <code>m = ((5 - 1) / 2) = 2</code> ,中位数 <code>arr[m]</code> 的值为 <code>6</code> 。</li>
38-
<li>例如 <code>arr =&nbsp;[-7, 22, 17,&thinsp;3]</code>,<code>n = 4</code>:数组排序后得到&nbsp;<code>arr = [-7, 3, 17, 22]</code> ,数组的中间位置为&nbsp;<code>m = ((4 - 1) / 2) = 1</code> ,中位数 <code>arr[m]</code> 的值为 <code>3</code> 。</li>
38+
<li>例如 <code>arr =&nbsp;[-7, 22, 17,3]</code>,<code>n = 4</code>:数组排序后得到&nbsp;<code>arr = [-7, 3, 17, 22]</code> ,数组的中间位置为&nbsp;<code>m = ((4 - 1) / 2) = 1</code> ,中位数 <code>arr[m]</code> 的值为 <code>3</code> 。</li>
3939
</ul>
4040

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

4343
<p><strong>示例 1:</strong></p>
4444

45-
<pre><strong>输入:</strong>arr = [1,2,3,4,5], k = 2
45+
<pre>
46+
<strong>输入:</strong>arr = [1,2,3,4,5], k = 2
4647
<strong>输出:</strong>[5,1]
4748
<strong>解释:</strong>中位数为 3,按从强到弱顺序排序后,数组变为 [5,1,4,2,3]。最强的两个元素是 [5, 1]。[1, 5] 也是正确答案。
4849
注意,尽管 |5 - 3| == |1 - 3| ,但是 5 比 1 更强,因为 5 &gt; 1 。
4950
</pre>
5051

5152
<p><strong>示例 2:</strong></p>
5253

53-
<pre><strong>输入:</strong>arr = [1,1,3,5,5], k = 2
54+
<pre>
55+
<strong>输入:</strong>arr = [1,1,3,5,5], k = 2
5456
<strong>输出:</strong>[5,5]
5557
<strong>解释:</strong>中位数为 3, 按从强到弱顺序排序后,数组变为 [5,5,1,1,3]。最强的两个元素是 [5, 5]。
5658
</pre>
5759

5860
<p><strong>示例 3:</strong></p>
5961

60-
<pre><strong>输入:</strong>arr = [6,7,11,7,6,8], k = 5
62+
<pre>
63+
<strong>输入:</strong>arr = [6,7,11,7,6,8], k = 5
6164
<strong>输出:</strong>[11,8,6,6,7]
6265
<strong>解释:</strong>中位数为 7, 按从强到弱顺序排序后,数组变为 [11,8,6,6,7,7]。
63-
[11,8,6,6,7] 的任何排列都是正确答案。</pre>
64-
65-
<p><strong>示例 4:</strong></p>
66-
67-
<pre><strong>输入:</strong>arr = [6,-3,7,2,11], k = 3
68-
<strong>输出:</strong>[-3,11,2]
69-
</pre>
70-
71-
<p><strong>示例 5:</strong></p>
72-
73-
<pre><strong>输入:</strong>arr = [-7,22,17,3], k = 2
74-
<strong>输出:</strong>[22,17]
66+
[11,8,6,6,7] 的任何排列都是正确答案。
7567
</pre>
7668

7769
<p>&nbsp;</p>
7870

7971
<p><strong>提示:</strong></p>
8072

8173
<ul>
82-
<li><code>1 &lt;= arr.length &lt;= 10^5</code></li>
83-
<li><code>-10^5 &lt;= arr[i] &lt;= 10^5</code></li>
74+
<li><code>1 &lt;= arr.length &lt;= 10<sup>5</sup></code></li>
75+
<li><code>-10<sup>5</sup> &lt;= arr[i] &lt;= 10<sup>5</sup></code></li>
8476
<li><code>1 &lt;= k &lt;= arr.length</code></li>
8577
</ul>
8678

solution/1400-1499/1471.The k Strongest Values in an Array/README_EN.md

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,43 @@ tags:
2222

2323
<p>Given an array of integers <code>arr</code> and an integer <code>k</code>.</p>
2424

25-
<p>A value <code>arr[i]</code> is said to be stronger than a value <code>arr[j]</code> if <code>|arr[i] - m| &gt; |arr[j] - m|</code> where <code>m</code> is the <strong>median</strong> of the array.<br />
25+
<p>A value <code>arr[i]</code> is said to be stronger than a value <code>arr[j]</code> if <code>|arr[i] - m| &gt; |arr[j] - m|</code> where <code>m</code> is the <strong>centre</strong> of the array.<br />
2626
If <code>|arr[i] - m| == |arr[j] - m|</code>, then <code>arr[i]</code> is said to be stronger than <code>arr[j]</code> if <code>arr[i] &gt; arr[j]</code>.</p>
2727

2828
<p>Return <em>a list of the strongest <code>k</code></em> values in the array. return the answer <strong>in any arbitrary order</strong>.</p>
2929

30-
<p><strong>Median</strong> is the middle value in an ordered integer list. More formally, if the length of the list is n, the median is the element in position <code>((n - 1) / 2)</code> in the sorted list <strong>(0-indexed)</strong>.</p>
30+
<p>The <strong>centre</strong> is the middle value in an ordered integer list. More formally, if the length of the list is n, the centre is the element in position <code>((n - 1) / 2)</code> in the sorted list <strong>(0-indexed)</strong>.</p>
3131

3232
<ul>
33-
<li>For <code>arr = [6, -3, 7, 2, 11]</code>, <code>n = 5</code> and the median is obtained by sorting the array <code>arr = [-3, 2, 6, 7, 11]</code> and the median is <code>arr[m]</code> where <code>m = ((5 - 1) / 2) = 2</code>. The median is <code>6</code>.</li>
34-
<li>For <code>arr = [-7, 22, 17,&thinsp;3]</code>, <code>n = 4</code> and the median is obtained by sorting the array <code>arr = [-7, 3, 17, 22]</code> and the median is <code>arr[m]</code> where <code>m = ((4 - 1) / 2) = 1</code>. The median is <code>3</code>.</li>
33+
<li>For <code>arr = [6, -3, 7, 2, 11]</code>, <code>n = 5</code> and the centre is obtained by sorting the array <code>arr = [-3, 2, 6, 7, 11]</code> and the centre is <code>arr[m]</code> where <code>m = ((5 - 1) / 2) = 2</code>. The centre is <code>6</code>.</li>
34+
<li>For <code>arr = [-7, 22, 17,&thinsp;3]</code>, <code>n = 4</code> and the centre is obtained by sorting the array <code>arr = [-7, 3, 17, 22]</code> and the centre is <code>arr[m]</code> where <code>m = ((4 - 1) / 2) = 1</code>. The centre is <code>3</code>.</li>
3535
</ul>
3636

37+
<div class="simple-translate-system-theme" id="simple-translate">
38+
<div>
39+
<div class="simple-translate-button isShow" style="background-image: url(&quot;moz-extension://8a9ffb6b-7e69-4e93-aae1-436a1448eff6/icons/512.png&quot;); height: 22px; width: 22px; top: 266px; left: 381px;">&nbsp;</div>
40+
41+
<div class="simple-translate-panel " style="width: 300px; height: 200px; top: 0px; left: 0px; font-size: 13px;">
42+
<div class="simple-translate-result-wrapper" style="overflow: hidden;">
43+
<div class="simple-translate-move" draggable="true">&nbsp;</div>
44+
45+
<div class="simple-translate-result-contents">
46+
<p class="simple-translate-result" dir="auto">&nbsp;</p>
47+
48+
<p class="simple-translate-candidate" dir="auto">&nbsp;</p>
49+
</div>
50+
</div>
51+
</div>
52+
</div>
53+
</div>
54+
3755
<p>&nbsp;</p>
3856
<p><strong class="example">Example 1:</strong></p>
3957

4058
<pre>
4159
<strong>Input:</strong> arr = [1,2,3,4,5], k = 2
4260
<strong>Output:</strong> [5,1]
43-
<strong>Explanation:</strong> Median is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also <strong>accepted</strong> answer.
61+
<strong>Explanation:</strong> Centre is 3, the elements of the array sorted by the strongest are [5,1,4,2,3]. The strongest 2 elements are [5, 1]. [1, 5] is also <strong>accepted</strong> answer.
4462
Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5 &gt; 1.
4563
</pre>
4664

@@ -49,15 +67,15 @@ Please note that although |5 - 3| == |1 - 3| but 5 is stronger than 1 because 5
4967
<pre>
5068
<strong>Input:</strong> arr = [1,1,3,5,5], k = 2
5169
<strong>Output:</strong> [5,5]
52-
<strong>Explanation:</strong> Median is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].
70+
<strong>Explanation:</strong> Centre is 3, the elements of the array sorted by the strongest are [5,5,1,1,3]. The strongest 2 elements are [5, 5].
5371
</pre>
5472

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

5775
<pre>
5876
<strong>Input:</strong> arr = [6,7,11,7,6,8], k = 5
5977
<strong>Output:</strong> [11,8,6,6,7]
60-
<strong>Explanation:</strong> Median is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].
78+
<strong>Explanation:</strong> Centre is 7, the elements of the array sorted by the strongest are [11,8,6,6,7,7].
6179
Any permutation of [11,8,6,6,7] is <strong>accepted</strong>.
6280
</pre>
6381

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tags:
2626
| content | varchar |
2727
+----------------+---------+
2828
在 SQL 中,tweet_id 是这个表的主键。
29-
content 只包含美式键盘上的字符,不包含其它特殊字符。
29+
content 只包含字母数字字符,'!',' ',不包含其它特殊字符。
3030
这个表包含某社交媒体 App 中所有的推文。</pre>
3131

3232
<p>&nbsp;</p>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ tags:
2626
| content | varchar |
2727
+----------------+---------+
2828
tweet_id is the primary key (column with unique values) for this table.
29-
content consists of characters on an American Keyboard, and no other special characters.
29+
content consists of alphanumeric characters, &#39;!&#39;, or &#39; &#39; and no other special characters.
3030
This table contains all the tweets in a social media app.
3131
</pre>
3232

solution/2100-2199/2116.Check if a Parentheses String Can Be Valid/README.md

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

7171
<pre>
7272
<b>输入:</b>s = "(((())(((())", locked = "111111010111"
73-
<b>输出:</b>false
73+
<b>输出:</b>true
7474
<b>解释:</b>locked 允许我们改变 s[6] 和 s[8]。
7575
我们将 s[6] 和 s[8] 改为 ')' 使 s 变为有效字符串。
7676
</pre>

0 commit comments

Comments
 (0)