Skip to content

feat: update lc problems #4459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions solution/0100-0199/0134.Gas Station/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ tags:
<p><strong>提示:</strong></p>

<ul>
<li><code>gas.length == n</code></li>
<li><code>cost.length == n</code></li>
<li><code>n == gas.length == cost.length</code></li>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
<li>输入保证答案唯一。</li>
</ul>

<!-- description:end -->
Expand Down
1 change: 1 addition & 0 deletions solution/0100-0199/0134.Gas Station/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Therefore, you can&#39;t travel around the circuit once no matter where you star
<li><code>n == gas.length == cost.length</code></li>
<li><code>1 &lt;= n &lt;= 10<sup>5</sup></code></li>
<li><code>0 &lt;= gas[i], cost[i] &lt;= 10<sup>4</sup></code></li>
<li>The input is generated such that the answer is unique.</li>
</ul>

<!-- description:end -->
Expand Down
15 changes: 0 additions & 15 deletions solution/0100-0199/0195.Tenth Line/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,41 +23,26 @@ tags:
<p>Assume that <code>file.txt</code> has the following content:</p>

<pre>

Line 1

Line 2

Line 3

Line 4

Line 5

Line 6

Line 7

Line 8

Line 9

Line 10

</pre>

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

<pre>

Line 10

</pre>

<div class="spoilers"><b>Note:</b><br />

1. If the file contains less than 10 lines, what should you output?<br />

2. There&#39;s at least three different solutions. Try to explore all possibilities.</div>

<!-- description:end -->
Expand Down
4 changes: 0 additions & 4 deletions solution/0200-0299/0262.Trips and Users/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ id 是这张表的主键(具有唯一值的列)。
status 是一个表示行程状态的枚举类型,枚举成员为(‘completed’, ‘cancelled_by_driver’, ‘cancelled_by_client’) 。
</pre>

<p>&nbsp;</p>

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

<p>&nbsp;</p>

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

<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>
Expand Down
6 changes: 3 additions & 3 deletions solution/0200-0299/0262.Trips and Users/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The table holds all taxi trips. Each trip has a unique id, while client_id and d
Status is an ENUM (category) type of (&#39;completed&#39;, &#39;cancelled_by_driver&#39;, &#39;cancelled_by_client&#39;).
</pre>

<p>&nbsp;</p>
<p> </p>

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

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

<p>&nbsp;</p>
<p> </p>

<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>

<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>

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

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

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
20 changes: 2 additions & 18 deletions solution/0700-0799/0799.Champagne Tower/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,51 +27,35 @@ tags:
<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>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre>

<strong>Input:</strong> poured = 1, query_row = 1, query_glass = 1

<strong>Output:</strong> 0.00000

<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.

</pre>

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

<pre>

<strong>Input:</strong> poured = 2, query_row = 1, query_glass = 1

<strong>Output:</strong> 0.50000

<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.

</pre>

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

<pre>

<strong>Input:</strong> poured = 100000009, query_row = 33, query_glass = 17

<strong>Output:</strong> 1.00000

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>

<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>

<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>

<li><code>0 &lt;=&nbsp;poured &lt;= 10<sup>9</sup></code></li>
<li><code>0 &lt;= query_glass &lt;= query_row&nbsp;&lt; 100</code></li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
rating: 1779
source: 第 129 场周赛 Q4
tags:
- 位运算
- 哈希表
- 字符串
- 滑动窗口
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/1000-1099/1016.Bi
rating: 1779
source: Weekly Contest 129 Q4
tags:
- Bit Manipulation
- Hash Table
- String
- Sliding Window
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ tags:

<!-- problem:start -->

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

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

Expand Down
31 changes: 6 additions & 25 deletions solution/1000-1099/1070.Product Sales Analysis III/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,17 @@ product_id 是产品表的外键(reference 列)。
请注意,价格是按每单位计的。
</pre>

<p>&nbsp;</p>

<p>产品表&nbsp;<code>Product</code>:</p>

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

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

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

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

<p>结果格式如下例所示:</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
Expand All @@ -70,14 +59,6 @@ Sales 表:
| 2 | 100 | 2009 | 12 | 5000 |
| 7 | 200 | 2011 | 15 | 9000 |
+---------+------------+------+----------+-------+
Product 表:
+------------+--------------+
| product_id | product_name |
+------------+--------------+
| 100 | Nokia |
| 200 | Apple |
| 300 | Samsung |
+------------+--------------+
<strong>输出:</strong>
+------------+------------+----------+-------+
| product_id | first_year | quantity | price |
Expand Down
44 changes: 15 additions & 29 deletions solution/1000-1099/1070.Product Sales Analysis III/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,25 @@ tags:
+-------------+-------+
(sale_id, year) is the primary key (combination of columns with unique values) of this table.
product_id is a foreign key (reference column) to <code>Product</code> table.
Each row of this table shows a sale on the product product_id in a certain year.
Note that the price is per unit.
</pre>

<p> </p>

<p>Table: <code>Product</code></p>
Each row records a sale of a product in a given year.
A product may have multiple sales entries in the same year.
Note that the per-unit price.

<pre>
+--------------+---------+
| Column Name | Type |
+--------------+---------+
| product_id | int |
| product_name | varchar |
+--------------+---------+
product_id is the primary key (column with unique values) of this table.
Each row of this table indicates the product name of each product.
</pre>

<p> </p>

<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>
<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>

<p>Return the resulting table in <strong>any order</strong>.</p>
<ul data-end="1234" data-start="992">
<li data-end="1078" data-start="992">
<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>
</li>
<li data-end="1140" data-start="1079">
<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>
</li>
</ul>

<p>The result format is in the following example.</p>
<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 />
Return the result in any order.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand All @@ -70,14 +63,7 @@ Sales table:
| 2 | 100 | 2009 | 12 | 5000 |
| 7 | 200 | 2011 | 15 | 9000 |
+---------+------------+------+----------+-------+
Product table:
+------------+--------------+
| product_id | product_name |
+------------+--------------+
| 100 | Nokia |
| 200 | Apple |
| 300 | Samsung |
+------------+--------------+

<strong>Output:</strong>
+------------+------------+----------+-------+
| product_id | first_year | quantity | price |
Expand Down
13 changes: 1 addition & 12 deletions solution/1100-1199/1108.Defanging an IP Address/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,18 @@ tags:
<p>A <em>defanged&nbsp;IP address</em>&nbsp;replaces every period <code>&quot;.&quot;</code> with <code>&quot;[.]&quot;</code>.</p>

<p>&nbsp;</p>

<p><strong class="example">Example 1:</strong></p>

<pre><strong>Input:</strong> address = "1.1.1.1"

<strong>Output:</strong> "1[.]1[.]1[.]1"

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

<pre><strong>Input:</strong> address = "255.100.50.0"

<strong>Output:</strong> "255[.]100[.]50[.]0"

</pre>

<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>

<ul>

<li>The given <code>address</code> is a valid IPv4 address.</li>

<li>The given <code>address</code> is a valid IPv4 address.</li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,17 @@ tags:
<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>

<ul>

<li>It is the empty string, or</li>

<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>

<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>

<li>It is the empty string, or</li>
<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>
<li>It can be written as&nbsp;<code>(A)</code>, where&nbsp;<code>A</code>&nbsp;is a VPS.</li>
</ul>

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

<ul>

<li><code>depth(&quot;&quot;) = 0</code></li>

<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>

<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>

<li><code>depth(&quot;&quot;) = 0</code></li>
<li><code>depth(A + B) = max(depth(A), depth(B))</code>, where <code>A</code> and <code>B</code> are VPS&#39;s</li>
<li><code>depth(&quot;(&quot; + A + &quot;)&quot;) = 1 + depth(A)</code>, where <code>A</code> is a VPS.</li>
</ul>

<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>
Expand Down
Loading