Skip to content

Commit 490508b

Browse files
authored
feat: update lc problems (#4459)
1 parent 13ca332 commit 490508b

File tree

84 files changed

+878
-1151
lines changed

Some content is hidden

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

84 files changed

+878
-1151
lines changed

solution/0100-0199/0134.Gas Station/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ tags:
5757
<p><strong>提示:</strong></p>
5858

5959
<ul>
60-
<li><code>gas.length == n</code></li>
61-
<li><code>cost.length == n</code></li>
60+
<li><code>n == gas.length == cost.length</code></li>
6261
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
6362
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
63+
<li>输入保证答案唯一。</li>
6464
</ul>
6565

6666
<!-- description:end -->

solution/0100-0199/0134.Gas Station/README_EN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ Therefore, you can&#39;t travel around the circuit once no matter where you star
6060
<li><code>n == gas.length == cost.length</code></li>
6161
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
6262
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
63+
<li>The input is generated such that the answer is unique.</li>
6364
</ul>
6465

6566
<!-- description:end -->

solution/0100-0199/0195.Tenth Line/README_EN.md

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,41 +23,26 @@ tags:
2323
<p>Assume that <code>file.txt</code> has the following content:</p>
2424

2525
<pre>
26-
2726
Line 1
28-
2927
Line 2
30-
3128
Line 3
32-
3329
Line 4
34-
3530
Line 5
36-
3731
Line 6
38-
3932
Line 7
40-
4133
Line 8
42-
4334
Line 9
44-
4535
Line 10
46-
4736
</pre>
4837

4938
<p>Your script should output the tenth line, which is:</p>
5039

5140
<pre>
52-
5341
Line 10
54-
5542
</pre>
5643

5744
<div class="spoilers"><b>Note:</b><br />
58-
5945
1. If the file contains less than 10 lines, what should you output?<br />
60-
6146
2. There&#39;s at least three different solutions. Try to explore all possibilities.</div>
6247

6348
<!-- description:end -->

solution/0200-0299/0262.Trips and Users/README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ id 是这张表的主键(具有唯一值的列)。
3636
status 是一个表示行程状态的枚举类型,枚举成员为(‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’) 。
3737
</pre>
3838

39-
<p>&nbsp;</p>
40-
4139
<div class="original__bRMd">
4240
<div>
4341
<p>表:<code>Users</code></p>
@@ -57,8 +55,6 @@ users_id 是这张表的主键(具有唯一值的列)。
5755
banned 是一个表示用户是否被禁止的枚举类型,枚举成员为 (‘Yes’, ‘No’) 。
5856
</pre>
5957

60-
<p>&nbsp;</p>
61-
6258
<p><strong>取消率</strong> 的计算方式如下:(被司机或乘客取消的非禁止用户生成的订单数量) / (非禁止用户生成的订单总数)。</p>
6359

6460
<p>编写解决方案找出&nbsp;<code>"2013-10-01"</code><strong>&nbsp;</strong>至&nbsp;<code>"2013-10-03"</code><strong>&nbsp;</strong>期间有&nbsp;<strong>至少&nbsp;</strong>一次行程的非禁止用户(<strong>乘客和司机都必须未被禁止</strong>)的 <strong>取消率</strong>。非禁止用户即 banned 为 No 的用户,禁止用户即 banned 为 Yes 的用户。其中取消率 <code>Cancellation Rate</code> 需要四舍五入保留 <strong>两位小数</strong> 。</p>

solution/0200-0299/0262.Trips and Users/README_EN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The table holds all taxi trips. Each trip has a unique id, while client_id and d
3434
Status is an ENUM (category) type of (&#39;completed&#39;, &#39;cancelled_by_driver&#39;, &#39;cancelled_by_client&#39;).
3535
</pre>
3636

37-
<p>&nbsp;</p>
37+
<p> </p>
3838

3939
<p>Table: <code>Users</code></p>
4040

@@ -51,15 +51,15 @@ The table holds all users. Each user has a unique users_id, and role is an ENUM
5151
banned is an ENUM (category) type of (&#39;Yes&#39;, &#39;No&#39;).
5252
</pre>
5353

54-
<p>&nbsp;</p>
54+
<p> </p>
5555

5656
<p>The <strong>cancellation rate</strong> is computed by dividing the number of canceled (by client or driver) requests with unbanned users by the total number of requests with unbanned users on that day.</p>
5757

5858
<p>Write a solution to find the <strong>cancellation rate</strong> of requests with unbanned users (<strong>both client and driver must not be banned</strong>) each day between <code>&quot;2013-10-01&quot;</code> and <code>&quot;2013-10-03&quot;</code> with <strong>at least</strong> one trip. Round <code>Cancellation Rate</code> to <strong>two decimal</strong> points.</p>
5959

6060
<p>Return the result table in <strong>any order</strong>.</p>
6161

62-
<p>The&nbsp;result format is in the following example.</p>
62+
<p>The result format is in the following example.</p>
6363

6464
<p>&nbsp;</p>
6565
<p><strong class="example">Example 1:</strong></p>

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

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,51 +27,35 @@ tags:
2727
<p>Now after pouring some non-negative integer cups of champagne, return how full the <code>j<sup>th</sup></code> glass in the <code>i<sup>th</sup></code> row is (both <code>i</code> and <code>j</code> are 0-indexed.)</p>
2828

2929
<p>&nbsp;</p>
30-
3130
<p><strong class="example">Example 1:</strong></p>
3231

3332
<pre>
34-
3533
<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1
36-
3734
<strong>Output:</strong> 0.00000
38-
3935
<strong>Explanation:</strong> We poured 1 cup of champange to the top glass of the tower (which is indexed as (0, 0)). There will be no excess liquid so all the glasses under the top glass will remain empty.
40-
4136
</pre>
4237

4338
<p><strong class="example">Example 2:</strong></p>
4439

4540
<pre>
46-
4741
<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1
48-
4942
<strong>Output:</strong> 0.50000
50-
5143
<strong>Explanation:</strong> We poured 2 cups of champange to the top glass of the tower (which is indexed as (0, 0)). There is one cup of excess liquid. The glass indexed as (1, 0) and the glass indexed as (1, 1) will share the excess liquid equally, and each will get half cup of champange.
52-
5344
</pre>
5445

5546
<p><strong class="example">Example 3:</strong></p>
5647

5748
<pre>
58-
5949
<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17
60-
6150
<strong>Output:</strong> 1.00000
62-
6351
</pre>
6452

6553
<p>&nbsp;</p>
66-
6754
<p><strong>Constraints:</strong></p>
6855

6956
<ul>
70-
71-
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
72-
73-
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
74-
57+
<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
58+
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
7559
</ul>
7660

7761
<!-- description:end -->

solution/1000-1099/1016.Binary String With Substrings Representing 1 To N/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
55
rating: 1779
66
source: 第 129 场周赛 Q4
77
tags:
8+
- 位运算
9+
- 哈希表
810
- 字符串
11+
- 滑动窗口
912
---
1013

1114
<!-- problem:start -->

solution/1000-1099/1016.Binary String With Substrings Representing 1 To N/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
55
rating: 1779
66
source: Weekly Contest 129 Q4
77
tags:
8+
- Bit Manipulation
9+
- Hash Table
810
- String
11+
- Sliding Window
912
---
1013

1114
<!-- problem:start -->

solution/1000-1099/1062.Longest Repeating Substring/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tags:
1313

1414
<!-- problem:start -->
1515

16-
# [1062. 最长重复子串 🔒](https://leetcode.cn/problems/longest-repeating-substring)
16+
# [1062. 最长重复子串的长度 🔒](https://leetcode.cn/problems/longest-repeating-substring)
1717

1818
[English Version](/solution/1000-1099/1062.Longest%20Repeating%20Substring/README_EN.md)
1919

solution/1000-1099/1070.Product Sales Analysis III/README.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,17 @@ product_id 是产品表的外键(reference 列)。
3434
请注意,价格是按每单位计的。
3535
</pre>
3636

37-
<p>&nbsp;</p>
38-
39-
<p>产品表&nbsp;<code>Product</code>:</p>
40-
41-
<pre>
42-
+--------------+---------+
43-
| Column Name | Type |
44-
+--------------+---------+
45-
| product_id | int |
46-
| product_name | varchar |
47-
+--------------+---------+
48-
product_id 是这张表的主键(具有唯一值的列)。
49-
这张表的每一行都标识:每个产品的 id 和 产品名称。</pre>
37+
<p>编写解决方案,选出每个售出过的产品&nbsp;<strong>第一年</strong> 销售的 <strong>产品 id</strong>、<strong>年份</strong>、<strong>数量&nbsp;</strong>和 <strong>价格</strong>。</p>
5038

51-
<p>&nbsp;</p>
39+
<ul>
40+
<li>对每个 <code>product_id</code>,找到其在Sales表中首次出现的最早年份。</li>
41+
<li>返回该产品在该年度的 <strong>所有</strong> 销售条目。</li>
42+
</ul>
5243

53-
<p>编写解决方案,选出每个售出过的产品&nbsp;<strong>第一年</strong> 销售的 <strong>产品 id</strong><strong>年份</strong>、<strong>数量&nbsp;</strong>和 <strong>价格</strong>。</p>
44+
<p>返回一张有这些列的表:<strong>product_id</strong><strong>first_year</strong><strong>quantity&nbsp;</strong>和<strong>&nbsp;price</strong>。</p>
5445

5546
<p>结果表中的条目可以按 <strong>任意顺序</strong> 排列。</p>
5647

57-
<p>结果格式如下例所示:</p>
58-
5948
<p>&nbsp;</p>
6049

6150
<p><strong>示例 1:</strong></p>
@@ -70,14 +59,6 @@ Sales 表:
7059
| 2 | 100 | 2009 | 12 | 5000 |
7160
| 7 | 200 | 2011 | 15 | 9000 |
7261
+---------+------------+------+----------+-------+
73-
Product 表:
74-
+------------+--------------+
75-
| product_id | product_name |
76-
+------------+--------------+
77-
| 100 | Nokia |
78-
| 200 | Apple |
79-
| 300 | Samsung |
80-
+------------+--------------+
8162
<strong>输出:</strong>
8263
+------------+------------+----------+-------+
8364
| product_id | first_year | quantity | price |

solution/1000-1099/1070.Product Sales Analysis III/README_EN.md

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,25 @@ tags:
3030
+-------------+-------+
3131
(sale_id, year) is the primary key (combination of columns with unique values) of this table.
3232
product_id is a foreign key (reference column) to <code>Product</code> table.
33-
Each row of this table shows a sale on the product product_id in a certain year.
34-
Note that the price is per unit.
35-
</pre>
36-
37-
<p> </p>
38-
39-
<p>Table: <code>Product</code></p>
33+
Each row records a sale of a product in a given year.
34+
A product may have multiple sales entries in the same year.
35+
Note that the per-unit price.
4036

41-
<pre>
42-
+--------------+---------+
43-
| Column Name | Type |
44-
+--------------+---------+
45-
| product_id | int |
46-
| product_name | varchar |
47-
+--------------+---------+
48-
product_id is the primary key (column with unique values) of this table.
49-
Each row of this table indicates the product name of each product.
5037
</pre>
5138

52-
<p> </p>
53-
54-
<p>Write a solution to select the <strong>product id</strong>, <strong>year</strong>, <strong>quantity</strong>, and <strong>price</strong> for the <strong>first year</strong> of every product sold. If any product is bought multiple times in its first year, return all sales separately.</p>
39+
<p>Write a solution to find all sales that occurred in the <strong data-end="967" data-start="953">first year</strong> each product was sold.</p>
5540

56-
<p>Return the resulting table in <strong>any order</strong>.</p>
41+
<ul data-end="1234" data-start="992">
42+
<li data-end="1078" data-start="992">
43+
<p data-end="1078" data-start="994">For each <code data-end="1015" data-start="1003">product_id</code>, identify the earliest <code data-end="1045" data-start="1039">year</code> it appears in the <code data-end="1071" data-start="1064">Sales</code> table.</p>
44+
</li>
45+
<li data-end="1140" data-start="1079">
46+
<p data-end="1140" data-start="1081">Return <strong data-end="1095" data-start="1088">all</strong> sales entries for that product in that year.</p>
47+
</li>
48+
</ul>
5749

58-
<p>The result format is in the following example.</p>
50+
<p data-end="1234" data-start="1143">Return a table with the following columns: <strong>product_id</strong>,<strong> first_year</strong>, <strong>quantity, </strong>and<strong> price</strong>.<br />
51+
Return the result in any order.</p>
5952

6053
<p>&nbsp;</p>
6154
<p><strong class="example">Example 1:</strong></p>
@@ -70,14 +63,7 @@ Sales table:
7063
| 2 | 100 | 2009 | 12 | 5000 |
7164
| 7 | 200 | 2011 | 15 | 9000 |
7265
+---------+------------+------+----------+-------+
73-
Product table:
74-
+------------+--------------+
75-
| product_id | product_name |
76-
+------------+--------------+
77-
| 100 | Nokia |
78-
| 200 | Apple |
79-
| 300 | Samsung |
80-
+------------+--------------+
66+
8167
<strong>Output:</strong>
8268
+------------+------------+----------+-------+
8369
| product_id | first_year | quantity | price |

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

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,18 @@ tags:
2323
<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>
2424

2525
<p>&nbsp;</p>
26-
2726
<p><strong class="example">Example 1:</strong></p>
28-
2927
<pre><strong>Input:</strong> address = "1.1.1.1"
30-
3128
<strong>Output:</strong> "1[.]1[.]1[.]1"
32-
3329
</pre><p><strong class="example">Example 2:</strong></p>
34-
3530
<pre><strong>Input:</strong> address = "255.100.50.0"
36-
3731
<strong>Output:</strong> "255[.]100[.]50[.]0"
38-
3932
</pre>
40-
4133
<p>&nbsp;</p>
42-
4334
<p><strong>Constraints:</strong></p>
4435

4536
<ul>
46-
47-
<li>The given <code>address</code> is a valid IPv4 address.</li>
48-
37+
<li>The given <code>address</code> is a valid IPv4 address.</li>
4938
</ul>
5039

5140
<!-- description:end -->

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

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,17 @@ tags:
2222
<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>
2323

2424
<ul>
25-
26-
<li>It is the empty string, or</li>
27-
28-
<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>
29-
30-
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
31-
25+
<li>It is the empty string, or</li>
26+
<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>
27+
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
3228
</ul>
3329

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

3632
<ul>
37-
38-
<li><code>depth(&quot;&quot;) = 0</code></li>
39-
40-
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
41-
42-
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
43-
33+
<li><code>depth(&quot;&quot;) = 0</code></li>
34+
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
35+
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
4436
</ul>
4537

4638
<p>For example,&nbsp; <code>&quot;&quot;</code>,&nbsp;<code>&quot;()()&quot;</code>, and&nbsp;<code>&quot;()(()())&quot;</code>&nbsp;are VPS&#39;s (with nesting depths 0, 1, and 2), and <code>&quot;)(&quot;</code> and <code>&quot;(()&quot;</code> are not VPS&#39;s.</p>

0 commit comments

Comments
 (0)