Skip to content

Commit 60bc1d9

Browse files
committed
feat: add solutions to lc problems: No.2562~2565
* No.2562.Find the Array Concatenation Value * No.2563.Count the Number of Fair Pairs * No.2564.Substring XOR Queries * No.2565.Subsequence With the Minimum Score
1 parent a57a30c commit 60bc1d9

File tree

42 files changed

+1919
-82
lines changed

Some content is hidden

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

42 files changed

+1919
-82
lines changed

solution/0000-0099/0010.Regular Expression Matching/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
<ul>
4545
<li><code>1 &lt;= s.length&nbsp;&lt;= 20</code></li>
46-
<li><code>1 &lt;= p.length&nbsp;&lt;= 30</code></li>
46+
<li><code>1 &lt;= p.length&nbsp;&lt;= 20</code></li>
4747
<li><code>s</code> contains only lowercase English letters.</li>
4848
<li><code>p</code> contains only lowercase English letters, <code>&#39;.&#39;</code>, and&nbsp;<code>&#39;*&#39;</code>.</li>
4949
<li>It is guaranteed for each appearance of the character <code>&#39;*&#39;</code>, there will be a previous valid character to match.</li>

solution/0000-0099/0045.Jump Game II/README_EN.md

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
<ul>
3838
<li><code>1 &lt;= nums.length &lt;= 10<sup>4</sup></code></li>
3939
<li><code>0 &lt;= nums[i] &lt;= 1000</code></li>
40+
<li>It&#39;s guaranteed that you can reach <code>nums[n - 1]</code>.</li>
4041
</ul>
4142

4243
## Solutions

solution/0100-0199/0191.Number of 1 Bits/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Description
66

7-
<p>Write a function that takes an unsigned integer and returns the number of &#39;1&#39; bits it has (also known as the <a href="http://en.wikipedia.org/wiki/Hamming_weight" target="_blank">Hamming weight</a>).</p>
7+
<p>Write a function that takes&nbsp;the binary representation of an unsigned integer and returns the number of &#39;1&#39; bits it has (also known as the <a href="http://en.wikipedia.org/wiki/Hamming_weight" target="_blank">Hamming weight</a>).</p>
88

99
<p><strong>Note:</strong></p>
1010

solution/0400-0499/0460.LFU Cache/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ lfu.get(4); // return 4
5656
<p><strong>Constraints:</strong></p>
5757

5858
<ul>
59-
<li><code>0 &lt;= capacity&nbsp;&lt;= 10<sup>4</sup></code></li>
59+
<li><code>1 &lt;= capacity&nbsp;&lt;= 10<sup>4</sup></code></li>
6060
<li><code>0 &lt;= key &lt;= 10<sup>5</sup></code></li>
6161
<li><code>0 &lt;= value &lt;= 10<sup>9</sup></code></li>
6262
<li>At most <code>2 * 10<sup>5</sup></code>&nbsp;calls will be made to <code>get</code> and <code>put</code>.</li>

solution/0400-0499/0467.Unique Substrings in Wraparound String/README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -6,47 +6,47 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>把字符串 <code>s</code> 看作 <code>"abcdefghijklmnopqrstuvwxyz"</code>&nbsp;的无限环绕字符串,所以&nbsp;<code>s</code> 看起来是这样的:</p>
9+
<p>定义字符串&nbsp;<code>base</code>&nbsp;为一个&nbsp;<code>"abcdefghijklmnopqrstuvwxyz"</code>&nbsp;无限环绕的字符串,所以&nbsp;<code>base</code>&nbsp;看起来是这样的:</p>
1010

1111
<ul>
12-
<li><code>"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd...."</code></li>
12+
<li><code>"...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd...."</code>.</li>
1313
</ul>
1414

15-
<p>现在给定另一个字符串 <code>p</code> 。返回&nbsp;<code>s</code><strong>不同 </strong>的 <code>p</code> 的 <strong>非空子串</strong>&nbsp;的数量&nbsp;&nbsp;</p>
15+
<p>给你一个字符串&nbsp;<code>s</code> ,请你统计并返回&nbsp;<code>s</code>&nbsp;中有多少&nbsp;<strong>不同</strong><strong>非空子串</strong>&nbsp;也在&nbsp;<code>base</code>&nbsp;中出现。</p>
1616

1717
<p>&nbsp;</p>
1818

1919
<p><strong>示例&nbsp;1:</strong></p>
2020

2121
<pre>
22-
<strong>输入:</strong>p = "a"
22+
<strong>输入:</strong>s = "a"
2323
<strong>输出:</strong>1
24-
<strong>解释:</strong>字符串 s 中只有 p 的一个 "a" 子字符
24+
<strong>解释:</strong>字符串 s 的子字符串 "a" 在 base 中出现
2525
</pre>
2626

2727
<p><strong>示例 2:</strong></p>
2828

2929
<pre>
30-
<strong>输入:</strong>p = "cac"
30+
<strong>输入:</strong>s = "cac"
3131
<strong>输出:</strong>2
32-
<strong>解释:</strong>字符串 s 中只有 p 的两个子串 ("a", "c") 。
32+
<strong>解释:</strong>字符串 s 有两个子字符串 ("a", "c") 在 base 中出现
3333
</pre>
3434

3535
<p><strong>示例 3:</strong></p>
3636

3737
<pre>
38-
<strong>输入:</strong>p = "zab"
38+
<strong>输入:</strong>s = "zab"
3939
<strong>输出:</strong>6
40-
<strong>解释:</strong>在字符串 s 中有 p 的六个子串 ("z", "a", "b", "za", "ab", "zab") 。
40+
<strong>解释:</strong>字符串 s 有六个子字符串 ("z", "a", "b", "za", "ab", and "zab") 在 base 中出现
4141
</pre>
4242

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

4545
<p><strong>提示:</strong></p>
4646

4747
<ul>
48-
<li><code>1 &lt;= p.length &lt;= 10<sup>5</sup></code></li>
49-
<li><code>p</code>&nbsp;由小写英文字母组成</li>
48+
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
49+
<li><font color="#c7254e" face="Menlo, Monaco, Consolas, Courier New, monospace"><span style="font-size: 12.6px; background-color: rgb(249, 242, 244);">s</span></font> 由小写英文字母组成</li>
5050
</ul>
5151

5252
## 解法

solution/0400-0499/0472.Concatenated Words/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<p>Given an array of strings <code>words</code> (<strong>without duplicates</strong>), return <em>all the <strong>concatenated words</strong> in the given list of</em> <code>words</code>.</p>
88

9-
<p>A <strong>concatenated word</strong> is defined as a string that is comprised entirely of at least two shorter words in the given array.</p>
9+
<p>A <strong>concatenated word</strong> is defined as a string that is comprised entirely of at least two shorter words (not necesssarily distinct)&nbsp;in the given array.</p>
1010

1111
<p>&nbsp;</p>
1212
<p><strong class="example">Example 1:</strong></p>

solution/0600-0699/0646.Maximum Length of Pair Chain/README.md

+20-9
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,39 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>给出 <code>n</code> 个数对。 在每一个数对中,第一个数字总是比第二个数字小。</p>
9+
<p>给你一个由&nbsp;<code>n</code>&nbsp;个数对组成的数对数组&nbsp;<code>pairs</code>&nbsp;,其中&nbsp;<code>pairs[i] = [left<sub>i</sub>, right<sub>i</sub>]</code>&nbsp;&nbsp;<code>left<sub>i</sub>&nbsp;&lt; right<sub>i</sub></code><sub> 。</sub></p>
1010

11-
<p>现在,我们定义一种跟随关系,当且仅当 <code>b < c</code> 时,数对<code>(c, d)</code> 才可以跟在 <code>(a, b)</code> 后面。我们用这种形式来构造一个数对链。</p>
11+
<p>现在,我们定义一种 <strong>跟随</strong> 关系,当且仅当&nbsp;<code>b &lt; c</code>&nbsp;时,数对&nbsp;<code>p2 = [c, d]</code>&nbsp;才可以跟在&nbsp;<code>p1 = [a, b]</code>&nbsp;后面。我们用这种形式来构造 <strong>数对链</strong> 。</p>
1212

13-
<p>给定一个数对集合,找出能够形成的最长数对链的长度。你不需要用到所有的数对,你可以以任何顺序选择其中的一些数对来构造。</p>
13+
<p>找出并返回能够形成的 <strong>最长数对链的长度</strong> 。</p>
1414

15-
<p> </p>
15+
<p>你不需要用到所有的数对,你可以以任何顺序选择其中的一些数对来构造。</p>
1616

17-
<p><strong>示例:</strong></p>
17+
<p>&nbsp;</p>
18+
19+
<p><strong>示例 1:</strong></p>
1820

1921
<pre>
20-
<strong>输入:</strong>[[1,2], [2,3], [3,4]]
22+
<strong>输入:</strong>pairs =&nbsp;[[1,2], [2,3], [3,4]]
2123
<strong>输出:</strong>2
22-
<strong>解释:</strong>最长的数对链是 [1,2] -> [3,4]
24+
<strong>解释:</strong>最长的数对链是 [1,2] -&gt; [3,4]
2325
</pre>
2426

25-
<p> </p>
27+
<p><strong>示例 2:</strong></p>
28+
29+
<pre>
30+
<b>输入:</b>pairs = [[1,2],[7,8],[4,5]]
31+
<b>输出:</b>3
32+
<b>解释:</b>最长的数对链是 [1,2] -&gt; [4,5] -&gt; [7,8] 。</pre>
33+
34+
<p>&nbsp;</p>
2635

2736
<p><strong>提示:</strong></p>
2837

2938
<ul>
30-
<li>给出数对的个数在 <code>[1, 1000]</code> 范围内。</li>
39+
<li><code>n == pairs.length</code></li>
40+
<li><code>1 &lt;= n &lt;= 1000</code></li>
41+
<li><code>-1000 &lt;= left<sub>i</sub>&nbsp;&lt; right<sub>i</sub>&nbsp;&lt;= 1000</code></li>
3142
</ul>
3243

3344
## 解法

solution/1200-1299/1233.Remove Sub-Folders from the Filesystem/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323
<pre>
2424
<strong>输入:</strong>folder = ["/a","/a/b","/c/d","/c/d/e","/c/f"]
2525
<strong>输出:</strong>["/a","/c/d","/c/f"]
26-
<strong>解释:</strong>"/a/b/" 是 "/a" 的子文件夹,而 "/c/d/e" 是 "/c/d" 的子文件夹。
26+
<strong>解释:</strong>"/a/b" 是 "/a" 的子文件夹,而 "/c/d/e" 是 "/c/d" 的子文件夹。
2727
</pre>
2828

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

3131
<pre>
3232
<strong>输入:</strong>folder = ["/a","/a/b/c","/a/b/d"]
3333
<strong>输出:</strong>["/a"]
34-
<strong>解释:</strong>文件夹 "/a/b/c" 和 "/a/b/d/" 都会被删除,因为它们都是 "/a" 的子文件夹。
34+
<strong>解释:</strong>文件夹 "/a/b/c" 和 "/a/b/d" 都会被删除,因为它们都是 "/a" 的子文件夹。
3535
</pre>
3636

3737
<p><strong>示例 3:</strong></p>
@@ -49,7 +49,7 @@
4949
<li><code>2 &lt;= folder[i].length &lt;= 100</code></li>
5050
<li><code>folder[i]</code>&nbsp;只包含小写字母和 <code>'/'</code></li>
5151
<li><code>folder[i]</code>&nbsp;总是以字符 <code>'/'</code>&nbsp;起始</li>
52-
<li>每个文件夹名都是 <strong>唯一</strong> 的</li>
52+
<li><code>folder</code>&nbsp;每个元素都是 <strong>唯一</strong> 的</li>
5353
</ul>
5454

5555
## 解法

solution/1600-1699/1604.Alert Using Same Key-Card Three or More Times in a One Hour Period/README.md

+12-26
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
<!-- 这里写题目描述 -->
88

9-
<p>力扣公司的员工都使用员工卡来开办公室的门。每当一个员工使用一次他的员工卡,安保系统会记录下员工的名字和使用时间。如果一个员工在一小时时间内使用员工卡的次数大于等于三次,这个系统会自动发布一个 <strong>警告</strong> 。</p>
9+
<p>力扣公司的员工都使用员工卡来开办公室的门。每当一个员工使用一次他的员工卡,安保系统会记录下员工的名字和使用时间。如果一个员工在一小时时间内使用员工卡的次数大于等于三次,这个系统会自动发布一个 <strong>警告</strong>&nbsp;。</p>
1010

11-
<p>给你字符串数组 <code>keyName</code> 和 <code>keyTime</code> ,其中 <code>[keyName[i], keyTime[i]]</code> 对应一个人的名字和他在 <strong>某一天</strong> 内使用员工卡的时间。</p>
11+
<p>给你字符串数组&nbsp;<code>keyName</code>&nbsp;&nbsp;<code>keyTime</code> ,其中&nbsp;<code>[keyName[i], keyTime[i]]</code>&nbsp;对应一个人的名字和他在&nbsp;<strong>某一天</strong> 内使用员工卡的时间。</p>
1212

13-
<p>使用时间的格式是 <strong>24小时制</strong> ,形如<strong> "HH:MM"</strong> ,比方说 <code>"23:51"</code> 和 <code>"09:49"</code> 。</p>
13+
<p>使用时间的格式是 <strong>24小时制</strong>&nbsp;,形如<strong>&nbsp;"HH:MM"</strong>&nbsp;,比方说&nbsp;<code>"23:51"</code> 和&nbsp;<code>"09:49"</code>&nbsp;。</p>
1414

15-
<p>请你返回去重后的收到系统警告的员工名字,将它们按 <strong>字典序</strong><strong>升序 </strong>排序后返回。</p>
15+
<p>请你返回去重后的收到系统警告的员工名字,将它们按 <strong>字典序</strong><strong>升序&nbsp;</strong>排序后返回。</p>
1616

17-
<p>请注意 <code>"10:00"</code> - <code>"11:00"</code> 视为一个小时时间范围内,而 <code>"23:51"</code> - <code>"00:10"</code> 不被视为一小时内,因为系统记录的是某一天内的使用情况。</p>
17+
<p>请注意&nbsp;<code>"10:00"</code> - <code>"11:00"</code>&nbsp;视为一个小时时间范围内,而&nbsp;<code>"22:51"</code> - <code>"23:52"</code>&nbsp;不被视为一小时时间范围内。</p>
1818

19-
<p> </p>
19+
<p>&nbsp;</p>
2020

2121
<p><strong>示例 1:</strong></p>
2222

@@ -34,31 +34,17 @@
3434
<strong>解释:</strong>"bob" 在一小时内使用了 3 次员工卡("21:00","21:20","21:30")。
3535
</pre>
3636

37-
<p><strong>示例 3:</strong></p>
38-
39-
<pre>
40-
<strong>输入:</strong>keyName = ["john","john","john"], keyTime = ["23:58","23:59","00:01"]
41-
<strong>输出:</strong>[]
42-
</pre>
43-
44-
<p><strong>示例 4:</strong></p>
45-
46-
<pre>
47-
<strong>输入:</strong>keyName = ["leslie","leslie","leslie","clare","clare","clare","clare"], keyTime = ["13:00","13:20","14:00","18:00","18:51","19:30","19:49"]
48-
<strong>输出:</strong>["clare","leslie"]
49-
</pre>
50-
51-
<p> </p>
37+
<p>&nbsp;</p>
5238

5339
<p><strong>提示:</strong></p>
5440

5541
<ul>
56-
<li><code>1 <= keyName.length, keyTime.length <= 10<sup>5</sup></code></li>
42+
<li><code>1 &lt;= keyName.length, keyTime.length &lt;= 10<sup>5</sup></code></li>
5743
<li><code>keyName.length == keyTime.length</code></li>
58-
<li><code>keyTime</code> 格式为 <strong>"HH:MM" </strong>。</li>
59-
<li>保证 <code>[keyName[i], keyTime[i]]</code> 形成的二元对 <strong>互不相同 </strong>。</li>
60-
<li><code>1 <= keyName[i].length <= 10</code></li>
61-
<li><code>keyName[i]</code> 只包含小写英文字母。</li>
44+
<li><code>keyTime</code> 格式为&nbsp;<strong>"HH:MM"&nbsp;</strong>。</li>
45+
<li>保证&nbsp;<code>[keyName[i], keyTime[i]]</code>&nbsp;形成的二元对&nbsp;<strong>互不相同&nbsp;</strong>。</li>
46+
<li><code>1 &lt;= keyName[i].length &lt;= 10</code></li>
47+
<li><code>keyName[i]</code>&nbsp;只包含小写英文字母。</li>
6248
</ul>
6349

6450
## 解法

solution/1800-1899/1803.Count Pairs With XOR in a Range/README_EN.md

+4
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,13 @@
6565
<p><strong>Constraints:</strong></p>
6666

6767
<ul>
68+
6869
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
70+
6971
<li><code>1 &lt;= nums[i] &lt;= 2 * 10<sup>4</sup></code></li>
72+
7073
<li><code>1 &lt;= low &lt;= high &lt;= 2 * 10<sup>4</sup></code></li>
74+
7175
</ul>
7276

7377
## Solutions

solution/2500-2599/2550.Count Collisions of Monkeys on a Polygon/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<li>the vertex <code>(i - 1 + n) % n</code> in the counter-clockwise direction.</li>
1414
</ul>
1515

16-
<p>A <strong>collision</strong> happens if at least two monkeys reside on the same vertex after the movement.</p>
16+
<p>A <strong>collision</strong> happens if at least two monkeys reside on the same vertex after the movement or intersect&nbsp;on an edge.</p>
1717

1818
<p>Return <em>the number of ways the monkeys can move so that at least <strong>one collision</strong></em> <em> happens</em>. Since the answer may be very large, return it modulo <code>10<sup>9 </sup>+ 7</code>.</p>
1919

solution/2500-2599/2557.Maximum Number of Integers to Choose From a Range II/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
<pre>
2525
<strong>输入:</strong>banned = [1,4,6], n = 6, maxSum = 4
2626
<strong>输出:</strong>1
27-
<strong>解释:</strong>你可以选择整数 2 或 3 。
28-
2 和 3 在范围 [1, 6] 内,且它们都不在 banned 中,它们中的任何一个都没有超过 maxSum 。
27+
<strong>解释:</strong>你可以选择整数 3 。
28+
3 在范围 [1, 6] 内,且不在 banned 中,所选整数的和为 3 ,也没有超过 maxSum 。
2929
</pre>
3030

3131
<p><strong class="example">示例 2:</strong></p>
@@ -34,7 +34,7 @@
3434
<strong>输入:</strong>banned = [4,3,5,6], n = 7, maxSum = 18
3535
<strong>输出:</strong>3
3636
<strong>解释:</strong>你可以选择整数 1, 2&nbsp;和 7 。
37-
它们都在范围 [1, 7] 中,且都没出现在 banned 中,它们的和是 10 ,没有超过 maxSum 。
37+
它们都在范围 [1, 7] 中,且都没出现在 banned 中,所选整数的和为 10 ,没有超过 maxSum 。
3838
</pre>
3939

4040
<p>&nbsp;</p>

solution/2500-2599/2557.Maximum Number of Integers to Choose From a Range II/README_EN.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@
2121
<pre>
2222
<strong>Input:</strong> banned = [1,4,6], n = 6, maxSum = 4
2323
<strong>Output:</strong> 1
24-
<strong>Explanation:</strong> You can choose the integer 2 and 3.
25-
2 and 3 are are in the range [1, 6], both do not appear in banned, and their sum is 5, which does not exceed maxSum.
24+
<strong>Explanation:</strong> You can choose the integer 3.
25+
3 is in the range [1, 6], and do not appear in banned. The sum of the choosen integers is 3, which does not ecxeed maxSum.
2626
</pre>
2727

2828
<p><strong class="example">Example 2:</strong></p>
2929

3030
<pre>
3131
<strong>Input:</strong> banned = [4,3,5,6], n = 7, maxSum = 18
3232
<strong>Output:</strong> 3
33-
<strong>Explanation:</strong> You can choose the integers 1, 2, 3 and 7.
34-
All these integers are in the range [1, 7], all do not appear in banned, and their sum is 13, which does not exceed maxSum.
33+
<strong>Explanation:</strong> You can choose the integers 1, 2, and 7.
34+
All these integers are in the range [1, 7], all do not appear in banned, and their sum is 18, which does not exceed maxSum.
3535
</pre>
3636

3737
<p>&nbsp;</p>

solution/2500-2599/2560.House Robber IV/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<p>给你一个整数数组 <code>nums</code> 表示每间房屋存放的现金金额。形式上,从左起第 <code>i</code> 间房屋中放有 <code>nums[i]</code> 美元。</p>
1616

17-
<p>另给你一个整数数组 <code>k</code> ,表示窃贼将会窃取的 <strong>最少</strong> 房屋数。小偷总能窃取至少 <code>k</code> 间房屋。</p>
17+
<p>另给你一个整数&nbsp;<code>k</code> ,表示窃贼将会窃取的 <strong>最少</strong> 房屋数。小偷总能窃取至少 <code>k</code> 间房屋。</p>
1818

1919
<p>返回小偷的 <strong>最小</strong> 窃取能力。</p>
2020

0 commit comments

Comments
 (0)