Skip to content

Commit 2d716a9

Browse files
committed
feat: add solutions to lc problem: No.1756
No.1756.Design Most Recently Used Queue
1 parent 42bda89 commit 2d716a9

File tree

154 files changed

+802
-449
lines changed

Some content is hidden

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

154 files changed

+802
-449
lines changed

solution/0100-0199/0174.Dungeon Game/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ table.dungeon, .dungeon th, .dungeon td {
8787
<p><strong>说明:</strong></p>
8888

8989
<ul>
90-
9190
<li>
9291

9392
<p>骑士的健康点数没有上限。</p>
9493

9594
</li>
96-
9795
<li>任何房间都可能对骑士的健康点数造成威胁,也可能增加骑士的健康点数,包括骑士进入的左上角房间以及公主被监禁的右下角房间。</li>
9896

9997
</ul>

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

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,8 @@
99
<p>For simplicity sake, you may assume:</p>
1010

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

1916
</ul>
@@ -47,9 +44,7 @@ day 1
4744
<p><b>Note:</b></p>
4845

4946
<ul>
50-
5147
<li>Don&#39;t worry about handling ties, it is guaranteed that each word&#39;s frequency count is unique.</li>
52-
5348
<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>
5449

5550
</ul>

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

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

1111
<ul>
1212
<li>例如,<code>"abcde"</code> 可以缩写为:
13-
1413
<ul>
1514
<li><code>"a3e"</code>(<code>"bcd"</code> 变为 <code>"3"</code> )</li>
1615
<li><code>"1bcd1"</code>(<code>"a"</code> 和 <code>"e"</code> 都变为 <code>"1"</code>)<meta charset="UTF-8" /></li>

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

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

99
<ul>
1010
<li>For example, <code>&quot;abcde&quot;</code> can be abbreviated into:
11-
1211
<ul>
1312
<li><code>&quot;a3e&quot;</code> (<code>&quot;bcd&quot;</code> turned into <code>&quot;3&quot;</code>)</li>
1413
<li><code>&quot;1bcd1&quot;</code> (<code>&quot;a&quot;</code> and <code>&quot;e&quot;</code> both turned into <code>&quot;1&quot;</code>)</li>

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

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

35-
36-
3735
<p><strong>提示:</strong></p>
3836

3937
<ul>

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

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

31-
32-
3331
<p><strong>提示:</strong></p>
3432

3533
<ul>

solution/0500-0599/0587.Erect the Fence/README.md

-5
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,10 @@
4141
<p><strong>注意:</strong></p>
4242

4343
<ol>
44-
4544
<li>所有的树应当被围在一起。你不能剪断绳子来包围树或者把树分成一组以上。</li>
46-
4745
<li>输入的整数在 0 到 100 之间。</li>
48-
4946
<li>花园至少有一棵树。</li>
50-
5147
<li>所有树的坐标都是不同的。</li>
52-
5348
<li>输入的点<strong>没有</strong>顺序。输出顺序也没有要求。</li>
5449

5550
</ol>

solution/0500-0599/0594.Longest Harmonious Subsequence/README_EN.md

-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@
4949
<p><strong>Constraints:</strong></p>
5050

5151
<ul>
52-
5352
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
54-
5553
<li><code>-10<sup>9</sup> &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
5654

5755
</ul>

solution/0600-0699/0679.24 Game/README.md

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

1313
<ul>
1414
<li>除法运算符 <code>'/'</code> 表示实数除法,而不是整数除法。
15-
1615
<ul>
1716
<li>例如,&nbsp;<code>4 /(1 - 2 / 3)= 4 /(1 / 3)= 12</code>&nbsp;。</li>
1817
</ul>

solution/0600-0699/0679.24 Game/README_EN.md

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

1111
<ul>
1212
<li>The division operator <code>&#39;/&#39;</code> represents real division, not integer division.
13-
1413
<ul>
1514
<li>For example, <code>4 / (1 - 2 / 3) = 4 / (1 / 3) = 12</code>.</li>
1615
</ul>

solution/0700-0799/0745.Prefix and Suffix Search/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ WordFilter wordFilter = new WordFilter(["apple"]);
3131
wordFilter.f("a", "e"); // 返回 0 ,因为下标为 0 的单词的 prefix = "a" 且 suffix = 'e" 。
3232
</pre>
3333

34-
35-
3634
<p><strong>提示:</strong></p>
3735

3836
<ul>

solution/0700-0799/0753.Cracking the Safe/README_EN.md

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

1111
<ul>
1212
<li>For example, the correct password is <code>&quot;345&quot;</code> and you enter in <code>&quot;012345&quot;</code>:
13-
1413
<ul>
1514
<li>After typing <code>0</code>, the most recent <code>3</code> digits is <code>&quot;0&quot;</code>, which is incorrect.</li>
1615
<li>After typing <code>1</code>, the most recent <code>3</code> digits is <code>&quot;01&quot;</code>, which is incorrect.</li>

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

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

45-
46-
4745
<p><strong>提示:</strong></p>
4846

4947
<ul>

solution/0700-0799/0799.Champagne Tower/README_EN.md

-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,7 @@
5555
<p><strong>Constraints:</strong></p>
5656

5757
<ul>
58-
5958
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
60-
6159
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
6260

6361
</ul>

solution/0800-0899/0818.Race Car/README_EN.md

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

99
<ul>
1010
<li>When you get an instruction <code>&#39;A&#39;</code>, your car does the following:
11-
1211
<ul>
1312
<li><code>position += speed</code></li>
1413
<li><code>speed *= 2</code></li>

solution/0800-0899/0824.Goat Latin/README_EN.md

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

1111
<ul>
1212
<li>If a word begins with a vowel (<code>&#39;a&#39;</code>, <code>&#39;e&#39;</code>, <code>&#39;i&#39;</code>, <code>&#39;o&#39;</code>, or <code>&#39;u&#39;</code>), append <code>&quot;ma&quot;</code> to the end of the word.
13-
1413
<ul>
1514
<li>For example, the word <code>&quot;apple&quot;</code> becomes <code>&quot;applema&quot;</code>.</li>
1615
</ul>

solution/0800-0899/0827.Making A Large Island/README_EN.md

-4
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,9 @@
5151
<p><strong>Constraints:</strong></p>
5252

5353
<ul>
54-
5554
<li><code>n == grid.length</code></li>
56-
5755
<li><code>n == grid[i].length</code></li>
58-
5956
<li><code>1 &lt;= n &lt;= 500</code></li>
60-
6157
<li><code>grid[i][j]</code> is either <code>0</code> or <code>1</code>.</li>
6258

6359
</ul>

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

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

51-
52-
5351
<p><strong>提示:</strong></p>
5452

5553
<ul>

solution/0800-0899/0897.Increasing Order Search Tree/README_EN.md

-2
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@
3737
<p><strong>Constraints:</strong></p>
3838

3939
<ul>
40-
4140
<li>The number of nodes in the given tree will be in the range <code>[1, 100]</code>.</li>
42-
4341
<li><code>0 &lt;= Node.val &lt;= 1000</code></li>
4442

4543
</ul>

solution/0900-0999/0909.Snakes and Ladders/README.md

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

1515
<ul>
1616
<li>选定目标方格 <code>next</code> ,目标方格的编号符合范围&nbsp;<code>[curr + 1, min(curr + 6, n<sup>2</sup>)]</code> 。
17-
1817
<ul>
1918
<li>该选择模拟了掷 <strong>六面体骰子</strong> 的情景,无论棋盘大小如何,玩家最多只能有 6 个目的地。</li>
2019
</ul>

solution/0900-0999/0909.Snakes and Ladders/README_EN.md

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

1111
<ul>
1212
<li>Choose a destination square <code>next</code> with a label in the range <code>[curr + 1, min(curr + 6, n<sup>2</sup>)]</code>.
13-
1413
<ul>
1514
<li>This choice simulates the result of a standard <strong>6-sided die roll</strong>: i.e., there are always at most 6 destinations, regardless of the size of the board.</li>
1615
</ul>

solution/0900-0999/0930.Binary Subarrays With Sum/README_EN.md

+16-19
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,8 @@
4545
<p><strong>Constraints:</strong></p>
4646

4747
<ul>
48-
4948
<li><code>1 &lt;= nums.length &lt;= 3 * 10<sup>4</sup></code></li>
50-
5149
<li><code>nums[i]</code> is either <code>0</code> or <code>1</code>.</li>
52-
5350
<li><code>0 &lt;= goal &lt;= nums.length</code></li>
5451

5552
</ul>
@@ -221,22 +218,22 @@ func numSubarraysWithSum(nums []int, goal int) int {
221218
* @return {number}
222219
*/
223220
var numSubarraysWithSum = function (nums, goal) {
224-
let i1 = 0,
225-
i2 = 0,
226-
s1 = 0,
227-
s2 = 0,
228-
j = 0,
229-
ans = 0;
230-
const n = nums.length;
231-
while (j < n) {
232-
s1 += nums[j];
233-
s2 += nums[j];
234-
while (i1 <= j && s1 > goal) s1 -= nums[i1++];
235-
while (i2 <= j && s2 >= goal) s2 -= nums[i2++];
236-
ans += i2 - i1;
237-
++j;
238-
}
239-
return ans;
221+
let i1 = 0,
222+
i2 = 0,
223+
s1 = 0,
224+
s2 = 0,
225+
j = 0,
226+
ans = 0;
227+
const n = nums.length;
228+
while (j < n) {
229+
s1 += nums[j];
230+
s2 += nums[j];
231+
while (i1 <= j && s1 > goal) s1 -= nums[i1++];
232+
while (i2 <= j && s2 >= goal) s2 -= nums[i2++];
233+
ans += i2 - i1;
234+
++j;
235+
}
236+
return ans;
240237
};
241238
```
242239

solution/0900-0999/0936.Stamping The Sequence/README_EN.md

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

1111
<ul>
1212
<li>For example, if <code>stamp = &quot;abc&quot;</code> and <code>target = &quot;abcba&quot;</code>, then <code>s</code> is <code>&quot;?????&quot;</code> initially. In one turn you can:
13-
1413
<ul>
1514
<li>place <code>stamp</code> at index <code>0</code> of <code>s</code> to obtain <code>&quot;abc??&quot;</code>,</li>
1615
<li>place <code>stamp</code> at index <code>1</code> of <code>s</code> to obtain <code>&quot;?abc?&quot;</code>, or</li>

solution/0900-0999/0966.Vowel Spellchecker/README.md

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

1313
<ul>
1414
<li>大小写:如果查询匹配单词列表中的某个单词(<strong>不区分大小写</strong>),则返回的正确单词与单词列表中的大小写相同。
15-
1615
<ul>
1716
<li>例如:<code>wordlist = ["yellow"]</code>, <code>query = "YellOw"</code>: <code>correct = "yellow"</code></li>
1817
<li>例如:<code>wordlist = ["Yellow"]</code>, <code>query = "yellow"</code>: <code>correct = "Yellow"</code></li>

solution/0900-0999/0966.Vowel Spellchecker/README_EN.md

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

1111
<ul>
1212
<li>Capitalization: If the query matches a word in the wordlist (<strong>case-insensitive</strong>), then the query word is returned with the same case as the case in the wordlist.
13-
1413
<ul>
1514
<li>Example: <code>wordlist = [&quot;yellow&quot;]</code>, <code>query = &quot;YellOw&quot;</code>: <code>correct = &quot;yellow&quot;</code></li>
1615
<li>Example: <code>wordlist = [&quot;Yellow&quot;]</code>, <code>query = &quot;yellow&quot;</code>: <code>correct = &quot;Yellow&quot;</code></li>

solution/0900-0999/0972.Equal Rational Numbers/README.md

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

1313
<ul>
1414
<li><code>&lt;IntegerPart&gt;</code>&nbsp;
15-
1615
<ul>
1716
<li>例:&nbsp;<code>0</code>&nbsp;,<code>12</code>&nbsp;和&nbsp;<code>123</code>&nbsp;</li>
1817
</ul>

solution/0900-0999/0972.Equal Rational Numbers/README_EN.md

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

1111
<ul>
1212
<li><code>&lt;IntegerPart&gt;</code>
13-
1413
<ul>
1514
<li>For example, <code>12</code>, <code>0</code>, and <code>123</code>.</li>
1615
</ul>

solution/0900-0999/0978.Longest Turbulent Subarray/README.md

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

1515
<ul>
1616
<li>若&nbsp;<code>i &lt;= k &lt; j</code>&nbsp;:
17-
1817
<ul>
1918
<li>当 <code>k</code>&nbsp;为奇数时,&nbsp;<code>A[k] &gt; A[k+1]</code>,且</li>
2019
<li>当 <code>k</code> 为偶数时,<code>A[k] &lt; A[k+1]</code>;</li>

solution/0900-0999/0978.Longest Turbulent Subarray/README_EN.md

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

1313
<ul>
1414
<li>For <code>i &lt;= k &lt; j</code>:
15-
1615
<ul>
1716
<li><code>arr[k] &gt; arr[k + 1]</code> when <code>k</code> is odd, and</li>
1817
<li><code>arr[k] &lt; arr[k + 1]</code> when <code>k</code> is even.</li>

solution/1000-1099/1011.Capacity To Ship Packages Within D Days/README_EN.md

-2
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ Note that the cargo must be shipped in the order given, so using a ship of capac
8181
<p><strong>Constraints:</strong></p>
8282

8383
<ul>
84-
8584
<li><code>1 &lt;= days &lt;= weights.length &lt;= 5 * 10<sup>4</sup></code></li>
86-
8785
<li><code>1 &lt;= weights[i] &lt;= 500</code></li>
8886

8987
</ul>

solution/1000-1099/1096.Brace Expansion II/README.md

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

1313
<ul>
1414
<li>如果只给出单一的元素&nbsp;<code>x</code>,那么表达式表示的字符串就只有&nbsp;<code>"x"</code>。<code>R(x) = {x}</code>
15-
1615
<ul>
1716
<li>例如,表达式 <code>"a"</code> 表示字符串 <code>"a"</code>。</li>
1817
<li>而表达式 <code>"w"</code> 就表示字符串 <code>"w"</code>。</li>

solution/1100-1199/1108.Defanging an IP Address/README_EN.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
<p><strong>Constraints:</strong></p>
3030

3131
<ul>
32-
3332
<li>The given <code>address</code> is a valid IPv4 address.</li>
3433

3534
</ul>
@@ -60,7 +59,7 @@ class Solution {
6059

6160
```ts
6261
function defangIPaddr(address: string): string {
63-
return address.split('.').join('[.]');
62+
return address.split(".").join("[.]");
6463
}
6564
```
6665

solution/1100-1199/1111.Maximum Nesting Depth of Two Valid Parentheses Strings/README_EN.md

-6
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,17 @@
77
<p>A string is a <em>valid parentheses string</em>&nbsp;(denoted VPS) if and only if it consists of <code>&quot;(&quot;</code> and <code>&quot;)&quot;</code> characters only, and:</p>
88

99
<ul>
10-
1110
<li>It is the empty string, or</li>
12-
1311
<li>It can be written as&nbsp;<code>AB</code>&nbsp;(<code>A</code>&nbsp;concatenated with&nbsp;<code>B</code>), where&nbsp;<code>A</code>&nbsp;and&nbsp;<code>B</code>&nbsp;are VPS&#39;s, or</li>
14-
1512
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
1613

1714
</ul>
1815

1916
<p>We can&nbsp;similarly define the <em>nesting depth</em> <code>depth(S)</code> of any VPS <code>S</code> as follows:</p>
2017

2118
<ul>
22-
2319
<li><code>depth(&quot;&quot;) = 0</code></li>
24-
2520
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
26-
2721
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
2822

2923
</ul>

0 commit comments

Comments
 (0)