Skip to content

Commit dc30052

Browse files
committed
feat: update lc problems
1 parent 86b6841 commit dc30052

File tree

18 files changed

+97
-61
lines changed

18 files changed

+97
-61
lines changed

solution/0000-0099/0020.Valid Parentheses/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ol>
1212
<li>Open brackets must be closed by the same type of brackets.</li>
1313
<li>Open brackets must be closed in the correct order.</li>
14+
<li>Every close bracket has a corresponding open bracket of the same type.</li>
1415
</ol>
1516

1617
<p>&nbsp;</p>

solution/0000-0099/0031.Next Permutation/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<p>A <strong>permutation</strong> of an array of integers is an arrangement of its members into a sequence or linear order.</p>
88

99
<ul>
10-
<li>For example, for <code>arr = [1,2,3]</code>, the following are considered permutations of <code>arr</code>: <code>[1,2,3]</code>, <code>[1,3,2]</code>, <code>[3,1,2]</code>, <code>[2,3,1]</code>.</li>
10+
<li>For example, for <code>arr = [1,2,3]</code>, the following are all the permutations of <code>arr</code>: <code>[1,2,3], [1,3,2], [2, 1, 3], [2, 3, 1], [3,1,2], [3,2,1]</code>.</li>
1111
</ul>
1212

1313
<p>The <strong>next permutation</strong> of an array of integers is the next lexicographically greater permutation of its integer. More formally, if all the permutations of the array are sorted in one container according to their lexicographical order, then the <strong>next permutation</strong> of that array is the permutation that follows it in the sorted container. If such arrangement is not possible, the array must be rearranged as the lowest possible order (i.e., sorted in ascending order).</p>

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

Lines changed: 1 addition & 1 deletion
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> if it is a palindrome.</p>
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>
88

99
<p>&nbsp;</p>
1010
<p><strong>Example 1:</strong></p>

solution/0300-0399/0326.Power of Three/README_EN.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,23 @@
1414
<pre>
1515
<strong>Input:</strong> n = 27
1616
<strong>Output:</strong> true
17+
<strong>Explanation:</strong> 27 = 3<sup>3</sup>
1718
</pre>
1819

1920
<p><strong>Example 2:</strong></p>
2021

2122
<pre>
2223
<strong>Input:</strong> n = 0
2324
<strong>Output:</strong> false
25+
<strong>Explanation:</strong> There is no x where 3<sup>x</sup> = 0.
2426
</pre>
2527

2628
<p><strong>Example 3:</strong></p>
2729

2830
<pre>
29-
<strong>Input:</strong> n = 9
30-
<strong>Output:</strong> true
31+
<strong>Input:</strong> n = -1
32+
<strong>Output:</strong> false
33+
<strong>Explanation:</strong> There is no x where 3<sup>x</sup> = (-1).
3134
</pre>
3235

3336
<p>&nbsp;</p>

solution/0400-0499/0493.Reverse Pairs/README_EN.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,26 @@
1010

1111
<p>&nbsp;</p>
1212
<p><strong>Example 1:</strong></p>
13-
<pre><strong>Input:</strong> nums = [1,3,2,3,1]
13+
14+
<pre>
15+
<strong>Input:</strong> nums = [1,3,2,3,1]
1416
<strong>Output:</strong> 2
15-
</pre><p><strong>Example 2:</strong></p>
16-
<pre><strong>Input:</strong> nums = [2,4,3,5,1]
17+
<strong>Explanation:</strong> The reverse pairs are:
18+
(1, 4) --&gt; nums[1] = 3, nums[4] = 1, 3 &gt; 2 * 1
19+
(3, 4) --&gt; nums[3] = 3, nums[4] = 1, 3 &gt; 2 * 1
20+
</pre>
21+
22+
<p><strong>Example 2:</strong></p>
23+
24+
<pre>
25+
<strong>Input:</strong> nums = [2,4,3,5,1]
1726
<strong>Output:</strong> 3
27+
<strong>Explanation:</strong> The reverse pairs are:
28+
(1, 4) --&gt; nums[1] = 4, nums[4] = 1, 4 &gt; 2 * 1
29+
(2, 4) --&gt; nums[2] = 3, nums[4] = 1, 3 &gt; 2 * 1
30+
(3, 4) --&gt; nums[3] = 3, nums[4] = 1, 5 &gt; 2 * 1
1831
</pre>
32+
1933
<p>&nbsp;</p>
2034
<p><strong>Constraints:</strong></p>
2135

solution/0500-0599/0569.Median Employee Salary/README_EN.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Each row of this table indicates the company and the salary of one employee.
2020

2121
<p>&nbsp;</p>
2222

23-
<p>Write an SQL query to find the median salary of each company.</p>
23+
<p>Write an SQL query to find the rows that contain the median salary of each company. While calculating the median, when you sort the salaries of the company, break the ties by <code>id</code>.</p>
2424

2525
<p>Return the result table in <strong>any order</strong>.</p>
2626

@@ -63,6 +63,39 @@ Employee table:
6363
| 9 | B | 1154 |
6464
| 14 | C | 2645 |
6565
+----+---------+--------+
66+
<strong>Explanation:</strong>
67+
For company A, the rows sorted are as follows:
68+
+----+---------+--------+
69+
| id | company | salary |
70+
+----+---------+--------+
71+
| 3 | A | 15 |
72+
| 2 | A | 341 |
73+
| 5 | A | 451 | &lt;-- median
74+
| 6 | A | 513 | &lt;-- median
75+
| 1 | A | 2341 |
76+
| 4 | A | 15314 |
77+
+----+---------+--------+
78+
For company B, the rows sorted are as follows:
79+
+----+---------+--------+
80+
| id | company | salary |
81+
+----+---------+--------+
82+
| 8 | B | 13 |
83+
| 7 | B | 15 |
84+
| 12 | B | 234 | &lt;-- median
85+
| 11 | B | 1221 | &lt;-- median
86+
| 9 | B | 1154 |
87+
| 10 | B | 1345 |
88+
+----+---------+--------+
89+
For company C, the rows sorted are as follows:
90+
+----+---------+--------+
91+
| id | company | salary |
92+
+----+---------+--------+
93+
| 17 | C | 65 |
94+
| 13 | C | 2345 |
95+
| 14 | C | 2645 | &lt;-- median
96+
| 15 | C | 2645 |
97+
| 16 | C | 2652 |
98+
+----+---------+--------+
6699
</pre>
67100

68101
<p>&nbsp;</p>

solution/0500-0599/0599.Minimum Index Sum of Two Lists/README_EN.md

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,41 @@
44

55
## Description
66

7-
<p>Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings.</p>
7+
<p>Given two arrays of strings <code>list1</code> and <code>list2</code>, find the <strong>common strings with the least index sum</strong>.</p>
88

9-
<p>You need to help them find out their <b>common interest</b> with the <b>least list index sum</b>. If there is a choice tie between answers, output all of them with no order requirement. You could assume there always exists an answer.</p>
9+
<p>A <strong>common string</strong> is a string that appeared in both <code>list1</code> and <code>list2</code>.</p>
10+
11+
<p>A <strong>common string with the least index sum</strong> is a common string such that if it appeared at <code>list1[i]</code> and <code>list2[j]</code> then <code>i + j</code> should be the minimum value among all the other <strong>common strings</strong>.</p>
12+
13+
<p>Return <em>all the <strong>common strings with the least index sum</strong></em>. Return the answer in <strong>any order</strong>.</p>
1014

1115
<p>&nbsp;</p>
1216
<p><strong>Example 1:</strong></p>
1317

1418
<pre>
1519
<strong>Input:</strong> list1 = [&quot;Shogun&quot;,&quot;Tapioca Express&quot;,&quot;Burger King&quot;,&quot;KFC&quot;], list2 = [&quot;Piatti&quot;,&quot;The Grill at Torrey Pines&quot;,&quot;Hungry Hunter Steakhouse&quot;,&quot;Shogun&quot;]
1620
<strong>Output:</strong> [&quot;Shogun&quot;]
17-
<strong>Explanation:</strong> The only restaurant they both like is &quot;Shogun&quot;.
21+
<strong>Explanation:</strong> The only common string is &quot;Shogun&quot;.
1822
</pre>
1923

2024
<p><strong>Example 2:</strong></p>
2125

2226
<pre>
2327
<strong>Input:</strong> list1 = [&quot;Shogun&quot;,&quot;Tapioca Express&quot;,&quot;Burger King&quot;,&quot;KFC&quot;], list2 = [&quot;KFC&quot;,&quot;Shogun&quot;,&quot;Burger King&quot;]
2428
<strong>Output:</strong> [&quot;Shogun&quot;]
25-
<strong>Explanation:</strong> The restaurant they both like and have the least index sum is &quot;Shogun&quot; with index sum 1 (0+1).
29+
<strong>Explanation:</strong> The common string with the least index sum is &quot;Shogun&quot; with index sum = (0 + 1) = 1.
30+
</pre>
31+
32+
<p><strong>Example 3:</strong></p>
33+
34+
<pre>
35+
<strong>Input:</strong> list1 = [&quot;happy&quot;,&quot;sad&quot;,&quot;good&quot;], list2 = [&quot;sad&quot;,&quot;happy&quot;,&quot;good&quot;]
36+
<strong>Output:</strong> [&quot;sad&quot;,&quot;happy&quot;]
37+
<strong>Explanation:</strong> There are three common strings:
38+
&quot;happy&quot; with index sum = (0 + 1) = 1.
39+
&quot;sad&quot; with index sum = (1 + 0) = 1.
40+
&quot;good&quot; with index sum = (2 + 2) = 4.
41+
The strings with the least index sum are &quot;sad&quot; and &quot;happy&quot;.
2642
</pre>
2743

2844
<p>&nbsp;</p>
@@ -32,8 +48,8 @@
3248
<li><code>1 &lt;= list1.length, list2.length &lt;= 1000</code></li>
3349
<li><code>1 &lt;= list1[i].length, list2[i].length &lt;= 30</code></li>
3450
<li><code>list1[i]</code> and <code>list2[i]</code> consist of spaces <code>&#39; &#39;</code> and English letters.</li>
35-
<li>All the stings of <code>list1</code> are <strong>unique</strong>.</li>
36-
<li>All the stings of <code>list2</code>&nbsp;are <strong>unique</strong>.</li>
51+
<li>All the strings of <code>list1</code> are <strong>unique</strong>.</li>
52+
<li>All the strings of <code>list2</code> are <strong>unique</strong>.</li>
3753
</ul>
3854

3955
## Solutions

solution/0600-0699/0662.Maximum Width of Binary Tree/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class Solution:
9494
ans = max(ans, i - t[depth] + 1)
9595
dfs(root.left, depth + 1, i << 1)
9696
dfs(root.right, depth + 1, i << 1 | 1)
97-
97+
9898
ans = 1
9999
t = []
100100
dfs(root, 0, 1)
19.8 KB
Loading

solution/0800-0899/0871.Minimum Number of Refueling Stops/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ We made 2 refueling stops along the way, so we return 2.
4949
<ul>
5050
<li><code>1 &lt;= target, startFuel &lt;= 10<sup>9</sup></code></li>
5151
<li><code>0 &lt;= stations.length &lt;= 500</code></li>
52-
<li><code>0 &lt;= position<sub>i</sub> &lt;= position<sub>i+1</sub> &lt; target</code></li>
52+
<li><code>1 &lt;= position<sub>i</sub> &lt; position<sub>i+1</sub> &lt; target</code></li>
5353
<li><code>1 &lt;= fuel<sub>i</sub> &lt; 10<sup>9</sup></code></li>
5454
</ul>
5555

0 commit comments

Comments
 (0)