Skip to content

Commit dd9d1b0

Browse files
committed
feat: add solutions to lc problem: No.2464
No.2464.Minimum Subarrays in a Valid Split
1 parent d3cc835 commit dd9d1b0

File tree

38 files changed

+613
-58
lines changed

38 files changed

+613
-58
lines changed

solution/0100-0199/0152.Maximum Product Subarray/README_EN.md

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
## Description
66

7-
<p>Given an integer array <code>nums</code>, find a contiguous non-empty subarray within the array that has the largest product, and return <em>the product</em>.</p>
7+
<p>Given an integer array <code>nums</code>, find a <span data-keyword="subarray-nonempty">subarray</span> that has the largest product, and return <em>the product</em>.</p>
88

99
<p>The test cases are generated so that the answer will fit in a <strong>32-bit</strong> integer.</p>
1010

11-
<p>A <strong>subarray</strong> is a contiguous subsequence of the array.</p>
12-
1311
<p>&nbsp;</p>
1412
<p><strong class="example">Example 1:</strong></p>
1513

solution/0100-0199/0159.Longest Substring with At Most Two Distinct Characters/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code>, return <em>the length of the longest substring that contains at most <strong>two distinct characters</strong></em>.</p>
7+
<p>Given a string <code>s</code>, return <em>the length of the longest </em><span data-keyword="substring-nonempty"><em>substring</em></span><em> that contains at most <strong>two distinct characters</strong></em>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0100-0199/0192.Word Frequency/README_EN.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,39 @@
44

55
## Description
66

7-
<p>Write a bash script to calculate the frequency of each word in a text file <code>words.txt</code>.</p>
7+
<p>Write a bash script to calculate the <span data-keyword="frequency-textfile">frequency</span> of each word in a text file <code>words.txt</code>.</p>
88

99
<p>For simplicity sake, you may assume:</p>
1010

1111
<ul>
12-
<li><code>words.txt</code> contains only lowercase characters and space <code>&#39; &#39;</code> characters.</li>
13-
<li>Each word must consist of lowercase characters only.</li>
14-
<li>Words are separated by one or more whitespace characters.</li>
12+
<li><code>words.txt</code> contains only lowercase characters and space <code>&#39; &#39;</code> characters.</li>
13+
<li>Each word must consist of lowercase characters only.</li>
14+
<li>Words are separated by one or more whitespace characters.</li>
1515
</ul>
1616

1717
<p><strong class="example">Example:</strong></p>
1818

1919
<p>Assume that <code>words.txt</code> has the following content:</p>
2020

2121
<pre>
22-
2322
the day is sunny the the
24-
2523
the sunny is is
26-
2724
</pre>
2825

2926
<p>Your script should output the following, sorted by descending frequency:</p>
3027

3128
<pre>
32-
3329
the 4
34-
3530
is 3
36-
3731
sunny 2
38-
3932
day 1
40-
4133
</pre>
4234

4335
<p><b>Note:</b></p>
4436

4537
<ul>
46-
<li>Don&#39;t worry about handling ties, it is guaranteed that each word&#39;s frequency count is unique.</li>
47-
<li>Could you write it in one-line using <a href="http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html">Unix pipes</a>?</li>
38+
<li>Don&#39;t worry about handling ties, it is guaranteed that each word&#39;s frequency count is unique.</li>
39+
<li>Could you write it in one-line using <a href="http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-4.html">Unix pipes</a>?</li>
4840
</ul>
4941

5042
## Solutions

solution/0200-0299/0209.Minimum Size Subarray Sum/README_EN.md

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

55
## Description
66

7-
<p>Given an array of positive integers <code>nums</code> and a positive integer <code>target</code>, return the minimal length of a <strong>contiguous subarray</strong> <code>[nums<sub>l</sub>, nums<sub>l+1</sub>, ..., nums<sub>r-1</sub>, nums<sub>r</sub>]</code> of which the sum is greater than or equal to <code>target</code>. If there is no such subarray, return <code>0</code> instead.</p>
7+
<p>Given an array of positive integers <code>nums</code> and a positive integer <code>target</code>, return <em>the <strong>minimal length</strong> of a </em><span data-keyword="subarray-nonempty"><em>subarray</em></span><em> whose sum is greater than or equal to</em> <code>target</code>. If there is no such subarray, return <code>0</code> instead.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0200-0299/0214.Shortest Palindrome/README_EN.md

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

55
## Description
66

7-
<p>You are given a string <code>s</code>. You can convert <code>s</code> to a palindrome by adding characters in front of it.</p>
7+
<p>You are given a string <code>s</code>. You can convert <code>s</code> to a <span data-keyword="palindrome-string">palindrome</span> by adding characters in front of it.</p>
88

99
<p>Return <em>the shortest palindrome you can find by performing this transformation</em>.</p>
1010

solution/0200-0299/0234.Palindrome Linked List/README_EN.md

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

55
## Description
66

7-
<p>Given the <code>head</code> of a singly linked list, return <code>true</code><em> if it is a palindrome or </em><code>false</code><em> otherwise</em>.</p>
7+
<p>Given the <code>head</code> of a singly linked list, return <code>true</code><em> if it is a </em><span data-keyword="palindrome-sequence"><em>palindrome</em></span><em> or </em><code>false</code><em> otherwise</em>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

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

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

55
## Description
66

7-
<p>Given the <code>root</code> of a binary tree, return the number of <strong>uni-value</strong> subtrees.</p>
7+
<p>Given the <code>root</code> of a binary tree, return <em>the number of <strong>uni-value</strong> </em><span data-keyword="subtree"><em>subtrees</em></span>.</p>
88

99
<p>A <strong>uni-value subtree</strong> means all nodes of the subtree have the same value.</p>
1010

solution/0200-0299/0266.Palindrome Permutation/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code>, return <code>true</code> if a permutation of the string could form a palindrome.</p>
7+
<p>Given a string <code>s</code>, return <code>true</code> <em>if a permutation of the string could form a </em><span data-keyword="palindrome-string"><em><strong>palindrome</strong></em></span><em> and </em><code>false</code><em> otherwise</em>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0200-0299/0269.Alien Dictionary/README_EN.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66

77
<p>There is a new alien language that uses the English alphabet. However, the order among the letters is unknown to you.</p>
88

9-
<p>You are given a list of strings <code>words</code> from the alien language&#39;s dictionary, where the strings in <code>words</code> are <strong>sorted lexicographically</strong> by the rules of this new language.</p>
9+
<p>You are given a list of strings <code>words</code> from the alien language&#39;s dictionary, where the strings in <code>words</code> are <span data-keyword="lexicographically-smaller-string-alien"><strong>sorted lexicographically</strong></span> by the rules of this new language.</p>
1010

11-
<p>Return <em>a string of the unique letters in the new alien language sorted in <strong>lexicographically increasing order</strong> by the new language&#39;s rules. If there is no solution, return </em><code>&quot;&quot;</code><em>. If there are multiple solutions, return <strong>any of them</strong></em>.</p>
12-
13-
<p>A string <code>s</code> is <strong>lexicographically smaller</strong> than a string <code>t</code> if at the first letter where they differ, the letter in <code>s</code> comes before the letter in <code>t</code> in the alien language. If the first <code>min(s.length, t.length)</code> letters are the same, then <code>s</code> is smaller if and only if <code>s.length &lt; t.length</code>.</p>
11+
<p>Return <em>a string of the unique letters in the new alien language sorted in <strong>lexicographically increasing order</strong> by the new language&#39;s rules. </em>If there is no solution, return <code>&quot;&quot;</code><em>. </em>If there are multiple solutions, return<em> <strong>any of them</strong></em>.</p>
1412

1513
<p>&nbsp;</p>
1614
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0300.Longest Increasing Subsequence/README_EN.md

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

55
## Description
66

7-
<p>Given an integer array <code>nums</code>, return the length of the longest strictly increasing subsequence.</p>
8-
9-
<p>A <strong>subsequence</strong> is a sequence that can be derived from an array by deleting some or no elements without changing the order of the remaining elements. For example, <code>[3,6,2,7]</code> is a subsequence of the array <code>[0,3,1,6,2,2,7]</code>.</p>
7+
<p>Given an integer array <code>nums</code>, return <em>the length of the longest <strong>strictly increasing </strong></em><span data-keyword="subsequence-array"><em><strong>subsequence</strong></em></span>.</p>
108

119
<p>&nbsp;</p>
1210
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0316.Remove Duplicate Letters/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code>, remove duplicate letters so that every letter appears once and only once. You must make sure your result is <strong>the smallest in lexicographical order</strong> among all possible results.</p>
7+
<p>Given a string <code>s</code>, remove duplicate letters so that every letter appears once and only once. You must make sure your result is <span data-keyword="lexicographically-smaller-string"><strong>the smallest in lexicographical order</strong></span> among all possible results.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0320.Generalized Abbreviation/README_EN.md

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

55
## Description
66

7-
<p>A word&#39;s <strong>generalized abbreviation</strong> can be constructed by taking any number of <strong>non-overlapping</strong> and <strong>non-adjacent</strong> substrings and replacing them with their respective lengths.</p>
7+
<p>A word&#39;s <strong>generalized abbreviation</strong> can be constructed by taking any number of <strong>non-overlapping</strong> and <strong>non-adjacent</strong> <span data-keyword="substring-nonempty">substrings</span> and replacing them with their respective lengths.</p>
88

99
<ul>
1010
<li>For example, <code>&quot;abcde&quot;</code> can be abbreviated into:
@@ -21,6 +21,7 @@
2121
<li><code>&quot;22de&quot;</code> (<code>&quot;ab&quot;</code> turned into <code>&quot;2&quot;</code> and <code>&quot;bc&quot;</code> turned into <code>&quot;2&quot;</code>) is invalid as the substring chosen overlap.</li>
2222
</ul>
2323
</li>
24+
2425
</ul>
2526

2627
<p>Given a string <code>word</code>, return <em>a list of all the possible <strong>generalized abbreviations</strong> of</em> <code>word</code>. Return the answer in <strong>any order</strong>.</p>

solution/0300-0399/0325.Maximum Size Subarray Sum Equals k/README_EN.md

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

55
## Description
66

7-
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the maximum length of a subarray that sums to</em> <code>k</code>. If there is not one, return <code>0</code> instead.</p>
7+
<p>Given an integer array <code>nums</code> and an integer <code>k</code>, return <em>the maximum length of a </em><span data-keyword="subarray"><em>subarray</em></span><em> that sums to</em> <code>k</code>. If there is not one, return <code>0</code> instead.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0300-0399/0333.Largest BST Subtree/README_EN.md

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

55
## Description
66

7-
<p>Given the root of a binary tree, find the largest subtree, which is also a Binary Search Tree (BST), where the largest means subtree has the largest number of nodes.</p>
7+
<p>Given the root of a binary tree, find the largest <span data-keyword="subtree">subtree</span>, which is also a Binary Search Tree (BST), where the largest means subtree has the largest number of nodes.</p>
88

99
<p>A <strong>Binary Search Tree (BST)</strong> is a tree in which all the nodes follow the below-mentioned properties:</p>
1010

solution/0300-0399/0336.Palindrome Pairs/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
<strong>输出:</strong>[[0,1],[1,0]]
3333
</pre>
3434

35+
36+
3537
<p><strong>提示:</strong></p>
3638

3739
<ul>

solution/0300-0399/0336.Palindrome Pairs/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<ul>
1212
<li><code>0 &lt;= i, j &lt; word.length</code>,</li>
1313
<li><code>i != j</code>, and</li>
14-
<li><code>words[i] + words[j]</code> (the concatenation of the two strings) is a palindrome string.</li>
14+
<li><code>words[i] + words[j]</code> (the concatenation of the two strings) is a <span data-keyword="palindrome-string">palindrome</span>.</li>
1515
</ul>
1616

1717
<p>Return <em>an array of all the <strong>palindrome pairs</strong> of </em><code>words</code>.</p>

solution/0300-0399/0340.Longest Substring with At Most K Distinct Characters/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the length of the longest substring of</em> <code>s</code> <em>that contains at most</em> <code>k</code> <em><strong>distinct</strong> characters</em>.</p>
7+
<p>Given a string <code>s</code> and an integer <code>k</code>, return <em>the length of the longest </em><span data-keyword="substring-nonempty"><em>substring</em></span><em> of</em> <code>s</code> <em>that contains at most</em> <code>k</code> <em><strong>distinct</strong> characters</em>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/0500-0599/0554.Brick Wall/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
<strong>输出:</strong>3
2929
</pre>
3030

31+
32+
3133
<p><strong>提示:</strong></p>
3234

3335
<ul>

solution/0700-0799/0775.Global and Local Inversions/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
<strong>解释:</strong>有 2 个全局倒置,和 1 个局部倒置。
4343
</pre>
4444

45+
46+
4547
<p><strong>提示:</strong></p>
4648

4749
<ul>

solution/0800-0899/0830.Positions of Large Groups/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
<strong>输出:</strong>[]
4949
</pre>
5050

51+
52+
5153
<p><strong>提示:</strong></p>
5254

5355
<ul>

solution/0800-0899/0864.Shortest Path to Get All Keys/README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,12 @@
7575

7676
然后,我们可以使用广度优先搜索 $BFS$ 来解决本题。由于钥匙的个数范围是 $[1, 6]$,我们可以用一个二进制数来表示钥匙的状态,其中第 $i$ 位为 $1$ 表示第 $i$ 把钥匙已经获取到了,为 $0$ 表示第 $i$ 把钥匙还没有获取到。
7777

78-
比如,以下例子中,共有 $4$ 个位为 $1$,也就表示共有 $4$ 把钥匙已经获取到了。
78+
比如,以下例子中,共有 $4$ 个二进制位为 $1$,也就表示有 `'b', 'c', 'd', 'f'` $4$ 把钥匙已经获取到了。
7979

8080
```
8181
1 0 1 1 1 0
82+
^ ^ ^ ^
83+
f d c b
8284
```
8385

8486
我们定义一个队列 $q$ 来存储当前位置以及当前拥有的钥匙的状态,即 $(i, j, state)$,其中 $(i, j)$ 表示当前位置,$state$ 表示当前拥有的钥匙的状态,即 $state$ 的第 $i$ 位为 $1$ 表示当前拥有第 $i$ 把钥匙,否则表示当前没有第 $i$ 把钥匙。

solution/0800-0899/0864.Shortest Path to Get All Keys/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ class Solution {
159159
class Solution {
160160
public:
161161
const static inline vector<int> dirs = {-1, 0, 1, 0, -1};
162-
162+
163163
int shortestPathAllKeys(vector<string>& grid) {
164164
int m = grid.size(), n = grid[0].size();
165165
int k = 0;

solution/1000-1099/1081.Smallest Subsequence of Distinct Characters/README_EN.md

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

55
## Description
66

7-
<p>Given a string <code>s</code>, return <em>the lexicographically smallest subsequence of</em> <code>s</code> <em>that contains all the distinct characters of</em> <code>s</code> <em>exactly once</em>.</p>
7+
<p>Given a string <code>s</code>, return <em>the </em><span data-keyword="lexicographically-smaller-string"><em>lexicographically smallest</em></span> <span data-keyword="subsequence-string"><em>subsequence</em></span><em> of</em> <code>s</code> <em>that contains all the distinct characters of</em> <code>s</code> <em>exactly once</em>.</p>
88

99
<p>&nbsp;</p>
1010
<p><strong class="example">Example 1:</strong></p>

solution/1600-1699/1681.Minimum Incompatibility/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@
5858

5959
**方法一:状态压缩 + 记忆化搜索**
6060

61-
62-
6361
<!-- tabs:start -->
6462

6563
### **Python3**

solution/1600-1699/1684.Count the Number of Consistent Strings/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Solution:
6262
def countConsistentStrings(self, allowed: str, words: List[str]) -> int:
6363
def f(w):
6464
return reduce(or_, (1 << (ord(c) - ord('a')) for c in w))
65-
65+
6666
mask = f(allowed)
6767
return sum((mask | f(w)) == mask for w in words)
6868
```

0 commit comments

Comments
 (0)