Skip to content

Commit 3cdcdf9

Browse files
committed
feat: update lc problems
1 parent 7f77f4c commit 3cdcdf9

File tree

22 files changed

+614
-72
lines changed

22 files changed

+614
-72
lines changed

solution/0000-0099/0005.Longest Palindromic Substring/README_EN.md

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

77
<p>Given a string <code>s</code>, return <em>the longest palindromic substring</em> in <code>s</code>.</p>
88

9+
<p>A string is called a palindrome string if the reverse of that string is the same as the original string.</p>
10+
911
<p>&nbsp;</p>
1012
<p><strong>Example 1:</strong></p>
1113

solution/0600-0699/0672.Bulb Switcher II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<strong>解释:</strong>状态可以是:
5353
- 按压开关 1 ,[关, 关, 关]
5454
- 按压开关 2 ,[关, 开, 关]
55-
- 按压开关 3 ,[开, , 开]
55+
- 按压开关 3 ,[开, , 开]
5656
- 按压开关 4 ,[关, 开, 开]
5757
</pre>
5858

solution/0600-0699/0682.Baseball Game/README_EN.md

+29-11
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,36 @@
44

55
## Description
66

7-
<p>You are keeping score for a baseball game with strange rules. The game consists of several rounds, where the scores of past rounds may affect future rounds&#39; scores.</p>
7+
<p>You are keeping the scores for a baseball game with strange rules. At the beginning of the game, you start with an empty record.</p>
88

9-
<p>At the beginning of the game, you start with an empty record. You are given a list of strings <code>ops</code>, where <code>ops[i]</code> is the <code>i<sup>th</sup></code> operation you must apply to the record and is one of the following:</p>
9+
<p>You are given a list of strings <code>operations</code>, where <code>operations[i]</code> is the <code>i<sup>th</sup></code> operation you must apply to the record and is one of the following:</p>
1010

11-
<ol>
12-
<li>An integer <code>x</code> - Record a new score of <code>x</code>.</li>
13-
<li><code>&quot;+&quot;</code> - Record a new score that is the sum of the previous two scores. It is guaranteed there will always be two previous scores.</li>
14-
<li><code>&quot;D&quot;</code> - Record a new score that is double the previous score. It is guaranteed there will always be a previous score.</li>
15-
<li><code>&quot;C&quot;</code> - Invalidate the previous score, removing it from the record. It is guaranteed there will always be a previous score.</li>
16-
</ol>
11+
<ul>
12+
<li>An integer <code>x</code>.
13+
<ul>
14+
<li>Record a new score of <code>x</code>.</li>
15+
</ul>
16+
</li>
17+
<li><code>&#39;+&#39;</code>.
18+
<ul>
19+
<li>Record a new score that is the sum of the previous two scores.</li>
20+
</ul>
21+
</li>
22+
<li><code>&#39;D&#39;</code>.
23+
<ul>
24+
<li>Record a new score that is the double of the previous score.</li>
25+
</ul>
26+
</li>
27+
<li><code>&#39;C&#39;</code>.
28+
<ul>
29+
<li>Invalidate the previous score, removing it from the record.</li>
30+
</ul>
31+
</li>
32+
</ul>
33+
34+
<p>Return <em>the sum of all the scores on the record after applying all the operations</em>.</p>
1735

18-
<p>Return <em>the sum of all the scores on the record</em>. The test cases are generated so that the answer fits in a 32-bit integer.</p>
36+
<p>The test cases are generated such that the answer and all intermediate calculations fit in a <strong>32-bit</strong> integer and that all operations are valid.</p>
1937

2038
<p>&nbsp;</p>
2139
<p><strong>Example 1:</strong></p>
@@ -64,8 +82,8 @@ Since the record is empty, the total sum is 0.
6482
<p><strong>Constraints:</strong></p>
6583

6684
<ul>
67-
<li><code>1 &lt;= ops.length &lt;= 1000</code></li>
68-
<li><code>ops[i]</code> is <code>&quot;C&quot;</code>, <code>&quot;D&quot;</code>, <code>&quot;+&quot;</code>, or a string representing an integer in the range <code>[-3 * 10<sup>4</sup>, 3 * 10<sup>4</sup>]</code>.</li>
85+
<li><code>1 &lt;= operations.length &lt;= 1000</code></li>
86+
<li><code>operations[i]</code> is <code>&quot;C&quot;</code>, <code>&quot;D&quot;</code>, <code>&quot;+&quot;</code>, or a string representing an integer in the range <code>[-3 * 10<sup>4</sup>, 3 * 10<sup>4</sup>]</code>.</li>
6987
<li>For operation <code>&quot;+&quot;</code>, there will always be at least two previous scores on the record.</li>
7088
<li>For operations <code>&quot;C&quot;</code> and <code>&quot;D&quot;</code>, there will always be at least one previous score on the record.</li>
7189
</ul>

solution/0800-0899/0850.Rectangle Area II/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Solution {
226226
m.put(v, i);
227227
nums[i++] = v;
228228
}
229-
229+
230230
SegmentTree tree = new SegmentTree(nums);
231231
long ans = 0;
232232
for (i = 0; i < segs.length; ++i) {

solution/0800-0899/0850.Rectangle Area II/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class Solution {
197197
m.put(v, i);
198198
nums[i++] = v;
199199
}
200-
200+
201201
SegmentTree tree = new SegmentTree(nums);
202202
long ans = 0;
203203
for (i = 0; i < segs.length; ++i) {

solution/0800-0899/0850.Rectangle Area II/Solution.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,11 @@ def modify(self, u, l, r, k):
3131

3232
def pushup(self, u):
3333
if self.tr[u].cnt:
34-
self.tr[u].length = self.nums[self.tr[u].r + 1] - \
35-
self.nums[self.tr[u].l]
34+
self.tr[u].length = self.nums[self.tr[u].r + 1] - self.nums[self.tr[u].l]
3635
elif self.tr[u].l == self.tr[u].r:
3736
self.tr[u].length = 0
3837
else:
39-
self.tr[u].length = self.tr[u << 1].length + \
40-
self.tr[u << 1 | 1].length
38+
self.tr[u].length = self.tr[u << 1].length + self.tr[u << 1 | 1].length
4139

4240
@property
4341
def length(self):

solution/0800-0899/0854.K-Similar Strings/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

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

9-
<p>字符串 <code>s1</code> <code>s2</code> 是 <strong><code>k</code> 相似</strong> 的(对于某些非负整数 <code>k</code> ),如果我们可以交换 <code>s1</code> 中两个字母的位置正好 <code>k</code> 次,使结果字符串等于 <code>s2</code></p>
9+
<p>对于某些非负整数 <code>k</code> ,如果交换 <code>s1</code> 中两个字母的位置恰好 <code>k</code> 次,能够使结果字符串等于 <code>s2</code> ,则认为字符串 <code>s1</code> <code>s2</code> 的<strong> 相似度为 </strong><code>k</code><strong> </strong><strong>。</strong></p>
1010

11-
<p>给定两个字谜游戏 <code>s1</code> 和 <code>s2</code> ,返回 <code>s1</code> 和 <code>s2</code> 与 <strong><code>k</code> 相似&nbsp;</strong>的最小 <code>k</code> 。</p>
11+
<p>给你两个字母异位词 <code>s1</code> 和 <code>s2</code> ,返回 <code>s1</code> 和 <code>s2</code> 的相似度 <code>k</code><strong> </strong>的最小值。</p>
1212

1313
<p>&nbsp;</p>
1414

@@ -34,7 +34,7 @@
3434
<li><code>1 &lt;= s1.length &lt;= 20</code></li>
3535
<li><code>s2.length == s1.length</code></li>
3636
<li><code>s1</code>&nbsp;和&nbsp;<code>s2</code>&nbsp;&nbsp;只包含集合&nbsp;<code>{'a', 'b', 'c', 'd', 'e', 'f'}</code>&nbsp;中的小写字母</li>
37-
<li><code>s2</code> 是 <code>s1</code> 的一个字谜</li>
37+
<li><code>s2</code> 是 <code>s1</code> 的一个字母异位词</li>
3838
</ul>
3939

4040
## 解法

solution/1100-1199/1106.Parsing A Boolean Expression/README_EN.md

+27-18
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,56 @@
44

55
## Description
66

7-
<p>Return the result of evaluating a given boolean <code>expression</code>, represented as a string.</p>
8-
9-
<p>An expression can either be:</p>
7+
<p>A <strong>boolean expression</strong> is an expression that evaluates to either <code>true</code> or <code>false</code>. It can be in one of the following shapes:</p>
108

119
<ul>
12-
<li><code>&quot;t&quot;</code>, evaluating to <code>True</code>;</li>
13-
<li><code>&quot;f&quot;</code>, evaluating to <code>False</code>;</li>
14-
<li><code>&quot;!(expr)&quot;</code>, evaluating to the logical NOT of the inner expression <code>expr</code>;</li>
15-
<li><code>&quot;&amp;(expr1,expr2,...)&quot;</code>, evaluating to the logical AND of 2 or more inner expressions <code>expr1, expr2, ...</code>;</li>
16-
<li><code>&quot;|(expr1,expr2,...)&quot;</code>, evaluating to the logical OR of 2 or more inner expressions <code>expr1, expr2, ...</code></li>
10+
<li><code>&#39;t&#39;</code> that evaluates to <code>true</code>.</li>
11+
<li><code>&#39;f&#39;</code> that evaluates to <code>false</code>.</li>
12+
<li><code>&#39;!(subExpr)&#39;</code> that evaluates to <strong>the logical NOT</strong> of the inner expression <code>subExpr</code>.</li>
13+
<li><code>&#39;&amp;(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)&#39;</code> that evaluates to <strong>the logical AND</strong> of the inner expressions <code>subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub></code> where <code>n &gt;= 1</code>.</li>
14+
<li><code>&#39;|(subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub>)&#39;</code> that evaluates to <strong>the logical OR</strong> of the inner expressions <code>subExpr<sub>1</sub>, subExpr<sub>2</sub>, ..., subExpr<sub>n</sub></code> where <code>n &gt;= 1</code>.</li>
1715
</ul>
1816

17+
<p>Given a string <code>expression</code> that represents a <strong>boolean expression</strong>, return <em>the evaluation of that expression</em>.</p>
18+
19+
<p>It is <strong>guaranteed</strong> that the given expression is valid and follows the given rules.</p>
20+
1921
<p>&nbsp;</p>
20-
<p><strong>Example 1:</strong></p>
22+
<p><strong class="example">Example 1:</strong></p>
2123

2224
<pre>
23-
<strong>Input:</strong> expression = &quot;!(f)&quot;
24-
<strong>Output:</strong> true
25+
<strong>Input:</strong> expression = &quot;&amp;(|(f))&quot;
26+
<strong>Output:</strong> false
27+
<strong>Explanation:</strong>
28+
First, evaluate |(f) --&gt; f. The expression is now &quot;&amp;(f)&quot;.
29+
Then, evaluate &amp;(f) --&gt; f. The expression is now &quot;f&quot;.
30+
Finally, return false.
2531
</pre>
2632

27-
<p><strong>Example 2:</strong></p>
33+
<p><strong class="example">Example 2:</strong></p>
2834

2935
<pre>
30-
<strong>Input:</strong> expression = &quot;|(f,t)&quot;
36+
<strong>Input:</strong> expression = &quot;|(f,f,f,t)&quot;
3137
<strong>Output:</strong> true
38+
<strong>Explanation:</strong> The evaluation of (false OR false OR false OR true) is true.
3239
</pre>
3340

34-
<p><strong>Example 3:</strong></p>
41+
<p><strong class="example">Example 3:</strong></p>
3542

3643
<pre>
37-
<strong>Input:</strong> expression = &quot;&amp;(t,f)&quot;
38-
<strong>Output:</strong> false
44+
<strong>Input:</strong> expression = &quot;!(&amp;(f,t))&quot;
45+
<strong>Output:</strong> true
46+
<strong>Explanation:</strong>
47+
First, evaluate &amp;(f,t) --&gt; (false AND true) --&gt; false --&gt; f. The expression is now &quot;!(f)&quot;.
48+
Then, evaluate !(f) --&gt; NOT false --&gt; true. We return true.
3949
</pre>
4050

4151
<p>&nbsp;</p>
4252
<p><strong>Constraints:</strong></p>
4353

4454
<ul>
4555
<li><code>1 &lt;= expression.length &lt;= 2 * 10<sup>4</sup></code></li>
46-
<li><code>expression[i]</code> consists of characters in <code>{&#39;(&#39;, &#39;)&#39;, &#39;&amp;&#39;, &#39;|&#39;, &#39;!&#39;, &#39;t&#39;, &#39;f&#39;, &#39;,&#39;}</code>.</li>
47-
<li><code>expression</code> is a valid expression representing a boolean, as given in the description.</li>
56+
<li>expression[i] is one following characters: <code>&#39;(&#39;</code>, <code>&#39;)&#39;</code>, <code>&#39;&amp;&#39;</code>, <code>&#39;|&#39;</code>, <code>&#39;!&#39;</code>, <code>&#39;t&#39;</code>, <code>&#39;f&#39;</code>, and <code>&#39;,&#39;</code>.</li>
4857
</ul>
4958

5059
## Solutions

solution/1400-1499/1494.Parallel Courses II/README.md

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

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

9-
<p>给你一个整数&nbsp;<code>n</code>&nbsp;表示某所大学里课程的数目,编号为&nbsp;<code>1</code>&nbsp;&nbsp;<code>n</code>&nbsp;,数组&nbsp;<code>dependencies</code>&nbsp;中,&nbsp;<code>dependencies[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>&nbsp; 表示一个先修课的关系,也就是课程&nbsp;<code>x<sub>i</sub></code>&nbsp;必须在课程&nbsp;<code>y<sub>i</sub></code><sub>&nbsp;</sub>之前上。同时你还有一个整数&nbsp;<code>k</code>&nbsp;。</p>
9+
<p>给你一个整数&nbsp;<code>n</code>&nbsp;表示某所大学里课程的数目,编号为&nbsp;<code>1</code>&nbsp;&nbsp;<code>n</code>&nbsp;,数组&nbsp;<code>relations</code>&nbsp;中,&nbsp;<code>relations[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>&nbsp; 表示一个先修课的关系,也就是课程&nbsp;<code>x<sub>i</sub></code>&nbsp;必须在课程&nbsp;<code>y<sub>i</sub></code><sub>&nbsp;</sub>之前上。同时你还有一个整数&nbsp;<code>k</code>&nbsp;。</p>
1010

1111
<p>在一个学期中,你 <strong>最多</strong>&nbsp;可以同时上 <code>k</code>&nbsp;门课,前提是这些课的先修课在之前的学期里已经上过了。</p>
1212

@@ -16,25 +16,28 @@
1616

1717
<p><strong>示例 1:</strong></p>
1818

19-
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1494.Parallel%20Courses%20II/images/leetcode_parallel_courses_1.png" style="height: 164px; width: 300px;"></strong></p>
19+
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1494.Parallel%20Courses%20II/images/leetcode_parallel_courses_1.png" style="height: 164px; width: 300px;" /></strong></p>
2020

21-
<pre><strong>输入:</strong>n = 4, dependencies = [[2,1],[3,1],[1,4]], k = 2
21+
<pre>
22+
<strong>输入:</strong>n = 4, relations = [[2,1],[3,1],[1,4]], k = 2
2223
<strong>输出:</strong>3
2324
<strong>解释:</strong>上图展示了题目输入的图。在第一个学期中,我们可以上课程 2 和课程 3 。然后第二个学期上课程 1 ,第三个学期上课程 4 。
2425
</pre>
2526

2627
<p><strong>示例 2:</strong></p>
2728

28-
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1494.Parallel%20Courses%20II/images/leetcode_parallel_courses_2.png" style="height: 234px; width: 300px;"></strong></p>
29+
<p><strong><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1494.Parallel%20Courses%20II/images/leetcode_parallel_courses_2.png" style="height: 234px; width: 300px;" /></strong></p>
2930

30-
<pre><strong>输入:</strong>n = 5, dependencies = [[2,1],[3,1],[4,1],[1,5]], k = 2
31+
<pre>
32+
<strong>输入:</strong>n = 5, relations = [[2,1],[3,1],[4,1],[1,5]], k = 2
3133
<strong>输出:</strong>4
3234
<strong>解释:</strong>上图展示了题目输入的图。一个最优方案是:第一学期上课程 2 和 3,第二学期上课程 4 ,第三学期上课程 1 ,第四学期上课程 5 。
3335
</pre>
3436

3537
<p><strong>示例 3:</strong></p>
3638

37-
<pre><strong>输入:</strong>n = 11, dependencies = [], k = 2
39+
<pre>
40+
<strong>输入:</strong>n = 11, relations = [], k = 2
3841
<strong>输出:</strong>6
3942
</pre>
4043

@@ -45,11 +48,11 @@
4548
<ul>
4649
<li><code>1 &lt;= n &lt;= 15</code></li>
4750
<li><code>1 &lt;= k &lt;= n</code></li>
48-
<li><code>0 &lt;=&nbsp;dependencies.length &lt;= n * (n-1) / 2</code></li>
49-
<li><code>dependencies[i].length == 2</code></li>
51+
<li><code>0 &lt;=&nbsp;relations.length &lt;= n * (n-1) / 2</code></li>
52+
<li><code>relations[i].length == 2</code></li>
5053
<li><code>1 &lt;= x<sub>i</sub>, y<sub>i</sub>&nbsp;&lt;= n</code></li>
5154
<li><code>x<sub>i</sub> != y<sub>i</sub></code></li>
52-
<li>所有先修关系都是不同的,也就是说&nbsp;<code>dependencies[i] != dependencies[j]</code>&nbsp;。</li>
55+
<li>所有先修关系都是不同的,也就是说&nbsp;<code>relations[i] != relations[j]</code>&nbsp;。</li>
5356
<li>题目输入的图是个有向无环图。</li>
5457
</ul>
5558

0 commit comments

Comments
 (0)