Skip to content

feat: update lc problems #4613

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 3 commits into from
Aug 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
2 changes: 1 addition & 1 deletion solution/0400-0499/0427.Construct Quad Tree/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class Node {

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0400-0499/0427.Construct%20Quad%20Tree/images/new_top.png" style="height: 181px; width: 777px;" /></p>

<p>如果你想了解更多关于四叉树的内容,可以参考 <a href="https://en.wikipedia.org/wiki/Quadtree">wiki</a> 。</p>
<p>如果你想了解更多关于四叉树的内容,可以参考 <a href="https://baike.baidu.com/item/%E5%9B%9B%E5%8F%89%E6%A0%91">百科</a> 。</p>

<p><strong>四叉树格式:</strong></p>

Expand Down
2 changes: 1 addition & 1 deletion solution/0800-0899/0853.Car Fleet/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<p>There are <code>n</code> cars at given miles away from the starting mile 0, traveling to reach the mile <code>target</code>.</p>

<p>You are given two integer array <code>position</code> and <code>speed</code>, both of length <code>n</code>, where <code>position[i]</code> is the starting mile of the <code>i<sup>th</sup></code> car and <code>speed[i]</code> is the speed of the <code>i<sup>th</sup></code> car in miles per hour.</p>
<p>You are given two integer arrays&nbsp;<code>position</code> and <code>speed</code>, both of length <code>n</code>, where <code>position[i]</code> is the starting mile of the <code>i<sup>th</sup></code> car and <code>speed[i]</code> is the speed of the <code>i<sup>th</sup></code> car in miles per hour.</p>

<p>A car cannot pass another car, but it can catch up and then travel next to it at the speed of the slower car.</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,14 @@ Notice that node 4 is the last child of node 1.</pre>
<strong>Explanation:</strong> This example follows case 3 because node p is not in the sub-tree of node q and vice-versa. We can move node 3 with its sub-tree and make it as node 8&#39;s child.
</pre>

<p><strong class="example">Example 4:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1500-1599/1516.Move%20Sub-Tree%20of%20N-Ary%20Tree/images/untitled-diagramdrawio.png" style="width: 500px; height: 175px;" />
<pre>
<strong>Input:</strong> root = [1,null,2,3,null,4], p = 1, q = 4
<strong>Output:</strong> [4,null,1,null,2,3]
<strong>Explanation:</strong> This example follows case 1 because node q is in the sub-tree of node p. Disconnect 4 with its parent and move node 1 with its sub-tree and make it as node 4&#39;s child.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ tags:
<p>You are given a <strong>0-indexed</strong> integer array <code>piles</code>, where <code>piles[i]</code> represents the number of stones in the <code>i<sup>th</sup></code> pile, and an integer <code>k</code>. You should apply the following operation <strong>exactly</strong> <code>k</code> times:</p>

<ul>
<li>Choose any <code>piles[i]</code> and <strong>remove</strong> <code>ceil(piles[i] / 2)</code> stones from it.</li>
<li>Choose any <code>piles[i]</code> and <strong>remove</strong> <code>floor(piles[i] / 2)</code> stones from it.</li>
</ul>

<p><strong>Notice</strong> that you can apply the operation on the <strong>same</strong> pile more than once.</p>

<p>Return <em>the <strong>minimum</strong> possible total number of stones remaining after applying the </em><code>k</code><em> operations</em>.</p>

<p><code>ceil(x)</code> is the <b>smallest</b> integer that is <strong>greater</strong> than or <strong>equal</strong> to <code>x</code> (i.e., rounds <code>x</code> up).</p>
<p><code>floor(x)</code> is the <strong>largest</strong>&nbsp;integer that is <strong>smaller</strong> than or <strong>equal</strong> to <code>x</code> (i.e., rounds <code>x</code>&nbsp;down).</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
3 changes: 3 additions & 0 deletions solution/1900-1999/1994.The Number of Good Subsets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ source: 第 60 场双周赛 Q4
tags:
- 位运算
- 数组
- 哈希表
- 数学
- 动态规划
- 状态压缩
- 计数
- 数论
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ source: Biweekly Contest 60 Q4
tags:
- Bit Manipulation
- Array
- Hash Table
- Math
- Dynamic Programming
- Bitmask
- Counting
- Number Theory
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ session_type is an ENUM (category) type of (Viewer, Streamer).
This table contains user id, session start, session end, session id and session type.
</pre>

<p>Write a solution to find the the <strong>users</strong> who have had <strong>at least one</strong> <strong>consecutive session</strong> of the <strong>same</strong> type (either &#39;<strong>Viewer</strong>&#39; or &#39;<strong>Streamer</strong>&#39;) with a <strong>maximum</strong> gap of <code>12</code> hours <strong>between</strong> sessions.</p>
<p>Write a solution to find the the <strong>users</strong> who have had <strong>at least two</strong><strong>&nbsp;session</strong> of the <strong>same</strong> type (either &#39;<strong>Viewer</strong>&#39; or &#39;<strong>Streamer</strong>&#39;) with a <strong>maximum</strong> gap of <code>12</code> hours <strong>between</strong> sessions.</p>

<p>Return <em>the result table ordered by </em><code>user_id</code><em> in <b>ascending</b> order.</em></p>

Expand Down Expand Up @@ -68,7 +68,7 @@ Sessions table:
| 103 |
+---------+
<strong>Explanation:</strong>
- User ID 101 will not be included in the final output as they do not have any consecutive sessions of the same session type.
- User ID 101 will not be included in the final output as they do not have any two sessions of the same session type.
- User ID 102 will be included in the final output as they had two viewer sessions with session IDs 3 and 4, respectively, and the time gap between them was less than 12 hours.
- User ID 103 participated in two viewer sessions with a gap of less than 12 hours between them, identified by session IDs 10 and 11. Therefore, user 103 will be included in the final output.
Output table is ordered by user_id in increasing order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tags:
这张表的每一行包含任务标识,员工标识和每个任务的开始和结束时间。
</pre>

<p>编写一个解决方案来查找 <strong>每个</strong> 员工的任务 <strong>总持续时间</strong> 以及员工在任何时间点处理的 <strong>最大并发任务数</strong>。总时长应该 <strong>舍入</strong> 到最近的 <strong>整小时</strong>。</p>
<p>编写一个解决方案来查找 <strong>每个</strong> 员工的任务 <strong>总持续时间</strong> 以及员工在任何时间点处理的 <strong>最大并发任务数</strong>。总时长应该 <strong>向下取整</strong>&nbsp;到最近的 <strong>整小时</strong>。</p>

<p>返回结果表以&nbsp;<code>employee_id</code><strong> <em>升序</em></strong><em>&nbsp;排序。</em></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ product_id is the unique key for this table.
Each row of this table contains the ID and name of a product.
</pre>

<p>Write a solution to find all <strong>products</strong> whose names contain a <strong>sequence of exactly three digits in a row</strong>.&nbsp;</p>
<p>Write a solution to find all <strong>products</strong> whose names contain a <strong>sequence of exactly three consecutive digits in a row</strong>.&nbsp;</p>

<p>Return <em>the result table ordered by</em> <code>product_id</code> <em>in <strong>ascending</strong> order.</em></p>

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

<p><strong>Note</strong> that the name may contain multiple such sequences, but each should have length three.</p>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README.md
rating: 1319
source: 第 158 场双周赛 Q1
tags:
- 贪心
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README_EN.md
rating: 1319
source: Biweekly Contest 158 Q1
tags:
- Greedy
- Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README.md
rating: 1777
source: 第 158 场双周赛 Q2
tags:
- 数组
- 动态规划
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README_EN.md
rating: 1777
source: Biweekly Contest 158 Q2
tags:
- Array
- Dynamic Programming
Expand Down
2 changes: 2 additions & 0 deletions solution/3500-3599/3574.Maximize Subarray GCD Score/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README.md
rating: 2257
source: 第 158 场双周赛 Q3
tags:
- 数组
- 数学
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README_EN.md
rating: 2257
source: Biweekly Contest 158 Q3
tags:
- Array
- Math
Expand Down
2 changes: 2 additions & 0 deletions solution/3500-3599/3575.Maximum Good Subtree Score/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README.md
rating: 2359
source: 第 158 场双周赛 Q4
tags:
- 位运算
-
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README_EN.md
rating: 2359
source: Biweekly Contest 158 Q4
tags:
- Bit Manipulation
- Tree
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README.md
rating: 1489
source: 第 453 场周赛 Q1
tags:
- 贪心
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README_EN.md
rating: 1489
source: Weekly Contest 453 Q1
tags:
- Greedy
- Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README.md
rating: 1749
source: 第 453 场周赛 Q2
tags:
- 脑筋急转弯
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README_EN.md
rating: 1749
source: Weekly Contest 453 Q2
tags:
- Brainteaser
- Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README.md
rating: 2032
source: 第 453 场周赛 Q3
tags:
- 队列
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README_EN.md
rating: 2032
source: Weekly Contest 453 Q3
tags:
- Queue
- Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README.md
rating: 2492
source: 第 453 场周赛 Q4
tags:
- 贪心
- 字符串
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README_EN.md
rating: 2492
source: Weekly Contest 453 Q4
tags:
- Greedy
- String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3582.Generate%20Tag%20for%20Video%20Caption/README.md
rating: 1316
source: 第 454 场周赛 Q1
tags:
- 字符串
- 模拟
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3582.Generate%20Tag%20for%20Video%20Caption/README_EN.md
rating: 1316
source: Weekly Contest 454 Q1
tags:
- String
- Simulation
Expand Down
2 changes: 2 additions & 0 deletions solution/3500-3599/3583.Count Special Triplets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3583.Count%20Special%20Triplets/README.md
rating: 1509
source: 第 454 场周赛 Q2
tags:
- 数组
- 哈希表
Expand Down
2 changes: 2 additions & 0 deletions solution/3500-3599/3583.Count Special Triplets/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3583.Count%20Special%20Triplets/README_EN.md
rating: 1509
source: Weekly Contest 454 Q2
tags:
- Array
- Hash Table
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3584.Maximum%20Product%20of%20First%20and%20Last%20Elements%20of%20a%20Subsequence/README.md
rating: 1763
source: 第 454 场周赛 Q3
tags:
- 数组
- 双指针
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3584.Maximum%20Product%20of%20First%20and%20Last%20Elements%20of%20a%20Subsequence/README_EN.md
rating: 1763
source: Weekly Contest 454 Q3
tags:
- Array
- Two Pointers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3585.Find%20Weighted%20Median%20Node%20in%20Tree/README.md
rating: 2428
source: 第 454 场周赛 Q4
tags:
- 树
- 深度优先搜索
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3585.Find%20Weighted%20Median%20Node%20in%20Tree/README_EN.md
rating: 2428
source: Weekly Contest 454 Q4
tags:
- Tree
- Depth-First Search
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3587.Minimum%20Adjacent%20Swaps%20to%20Alternate%20Parity/README.md
rating: 1548
source: 第 159 场双周赛 Q1
tags:
- 贪心
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3587.Minimum%20Adjacent%20Swaps%20to%20Alternate%20Parity/README_EN.md
rating: 1548
source: Biweekly Contest 159 Q1
tags:
- Greedy
- Array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3588.Find%20Maximum%20Area%20of%20a%20Triangle/README.md
rating: 1818
source: 第 159 场双周赛 Q2
tags:
- 贪心
- 几何
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3588.Find%20Maximum%20Area%20of%20a%20Triangle/README_EN.md
rating: 1818
source: Biweekly Contest 159 Q2
tags:
- Greedy
- Geometry
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3589.Count%20Prime-Gap%20Balanced%20Subarrays/README.md
rating: 2235
source: 第 159 场双周赛 Q3
tags:
- 队列
- 数组
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3589.Count%20Prime-Gap%20Balanced%20Subarrays/README_EN.md
rating: 2235
source: Biweekly Contest 159 Q3
tags:
- Queue
- Array
Expand Down
2 changes: 2 additions & 0 deletions solution/3500-3599/3590.Kth Smallest Path XOR Sum/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3590.Kth%20Smallest%20Path%20XOR%20Sum/README.md
rating: 2645
source: 第 159 场双周赛 Q4
tags:
- 树
- 深度优先搜索
Expand Down
Loading
Loading