Skip to content

feat: update lc problems #3502

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 1 commit into from
Sep 10, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tags:

<pre><strong>输入:</strong>s = &quot;deeedbbcccbdaa&quot;, k = 3
<strong>输出:</strong>&quot;aa&quot;
<strong>解释:
<strong>解释:
</strong>先删除 &quot;eee&quot; 和 &quot;ccc&quot;,得到 &quot;ddbbbdaa&quot;
再删除 &quot;bbb&quot;,得到 &quot;dddaa&quot;
最后删除 &quot;ddd&quot;,得到 &quot;aa&quot;</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tags:
<pre>
<strong>Input:</strong> s = &quot;deeedbbcccbdaa&quot;, k = 3
<strong>Output:</strong> &quot;aa&quot;
<strong>Explanation:
<strong>Explanation:
</strong>First delete &quot;eee&quot; and &quot;ccc&quot;, get &quot;ddbbbdaa&quot;
Then delete &quot;bbb&quot;, get &quot;dddaa&quot;
Finally delete &quot;ddd&quot;, get &quot;aa&quot;</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ source: 第 178 场周赛 Q3
tags:
- 树
- 深度优先搜索
- 广度优先搜索
- 链表
- 二叉树
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ source: Weekly Contest 178 Q3
tags:
- Tree
- Depth-First Search
- Breadth-First Search
- Linked List
- Binary Tree
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tags:
<pre>
<strong>Input:</strong> head = [0,3,1,0,4,5,2,0]
<strong>Output:</strong> [4,11]
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The above figure represents the given linked list. The modified list contains
- The sum of the nodes marked in green: 3 + 1 = 4.
- The sum of the nodes marked in red: 4 + 5 + 2 = 11.
Expand All @@ -42,7 +42,7 @@ The above figure represents the given linked list. The modified list contains
<pre>
<strong>Input:</strong> head = [0,1,0,3,0,2,2,0]
<strong>Output:</strong> [1,3,4]
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The above figure represents the given linked list. The modified list contains
- The sum of the nodes marked in green: 1 = 1.
- The sum of the nodes marked in red: 3 = 3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ tags:
<pre>
<strong>Input:</strong> chargeTimes = [3,6,1,3,4], runningCosts = [2,1,3,4,5], budget = 25
<strong>Output:</strong> 3
<strong>Explanation:</strong>
<strong>Explanation:</strong>
It is possible to run all individual and consecutive pairs of robots within budget.
To obtain answer 3, consider the first 3 robots. The total cost will be max(3,6,1) + 3 * sum(2,1,3) = 6 + 3 * 6 = 24 which is less than 25.
It can be shown that it is not possible to run more than 3 consecutive robots within budget, so we return 3.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2400-2499/2472.Ma
rating: 2013
source: 第 319 场周赛 Q4
tags:
- 贪心
- 双指针
- 字符串
- 动态规划
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/2400-2499/2472.Ma
rating: 2013
source: Weekly Contest 319 Q4
tags:
- Greedy
- Two Pointers
- String
- Dynamic Programming
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ tags:
<ul>
<li>Only one worker can use the bridge at a time.</li>
<li>When the bridge is unused prioritize the <strong>least efficient</strong> worker on the right side to cross. If there are no workers on the right side, prioritize the <strong>least efficient</strong> worker on the left side to cross.</li>
<li>If enough workers have already been dispatched from the left side to pick up all the remaining boxes, <strong>no more</strong> workers will be sent from the left side.</li>
</ul>

<p>Return the <strong>elapsed minutes</strong> at which the last box reaches the <strong>left side of the bridge</strong>.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,38 +19,56 @@ tags:

<!-- description:start -->

<p>Given an array of integers called <code>nums</code>, you can perform the following operation while <code>nums</code> contains <strong>at least</strong> <code>2</code> elements:</p>
<p>You are given an array of integers <code>nums</code>. Consider the following operation:</p>

<ul>
<li>Choose the first two elements of <code>nums</code> and delete them.</li>
<li>Delete the first two elements <code>nums</code> and define the <em>score</em> of the operation as the sum of these two elements.</li>
</ul>

<p>The<strong> score</strong> of the operation is the sum of the deleted elements.</p>
<p>You can perform this operation until <code>nums</code> contains fewer than two elements. Additionally, the <strong>same</strong> <em>score</em> must be achieved in <strong>all</strong> operations.</p>

<p>Your task is to find the <strong>maximum</strong> number of operations that can be performed, such that <strong>all operations have the same score</strong>.</p>

<p>Return <em>the <strong>maximum</strong> number of operations possible that satisfy the condition mentioned above</em>.</p>
<p>Return the <strong>maximum</strong> number of operations you can perform.</p>

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

<pre>
<strong>Input:</strong> nums = [3,2,1,4,5]
<strong>Output:</strong> 2
<strong>Explanation:</strong> We perform the following operations:
- Delete the first two elements, with score 3 + 2 = 5, nums = [1,4,5].
- Delete the first two elements, with score 1 + 4 = 5, nums = [5].
We are unable to perform any more operations as nums contain only 1 element.</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [3,2,1,4,5]</span></p>

<p><strong>Output:</strong> <span class="example-io">2</span></p>

<p><strong>Explanation:</strong></p>

<ul>
<li>We can perform the first operation with the score <code>3 + 2 = 5</code>. After this operation, <code>nums = [1,4,5]</code>.</li>
<li>We can perform the second operation as its score is <code>4 + 1 = 5</code>, the same as the previous operation. After this operation, <code>nums = [5]</code>.</li>
<li>As there are fewer than two elements, we can&#39;t perform more operations.</li>
</ul>
</div>

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

<pre>
<strong>Input:</strong> nums = [3,2,6,1,4]
<strong>Output:</strong> 1
<strong>Explanation:</strong> We perform the following operations:
- Delete the first two elements, with score 3 + 2 = 5, nums = [6,1,4].
We are unable to perform any more operations as the score of the next operation isn&#39;t the same as the previous one.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [1,5,3,3,4,1,3,2,2,3]</span></p>

<p><strong>Output:</strong> <span class="example-io">1</span></p>

<p><strong>Explanation:</strong></p>

<ul>
<li>We can perform the first operation with the score <code>1 + 5 = 6</code>. After this operation, <code>nums = [3,3,4,1,3,2,2,3]</code>.</li>
<li>We can perform the second operation as its score is <code>3 + 3 = 6</code>, the same as the previous operation. After this operation, <code>nums = [4,1,3,2,2,3]</code>.</li>
<li>We cannot perform the next operation as its score is <code>4 + 1 = 5</code>, which is different from the previous scores.</li>
</ul>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">nums = [5,3]</span></p>

<p><strong>Output:</strong> <span class="example-io">1</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3279.Maximum%20Total%20Area%20Occupied%20by%20Pistons/README.md
tags:
- 数组
- 哈希表
- 字符串
- 计数
- 前缀和
- 模拟
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3279.Maximum%20Total%20Area%20Occupied%20by%20Pistons/README_EN.md
tags:
- Array
- Hash Table
- String
- Counting
- Prefix Sum
- Simulation
---

<!-- problem:start -->
Expand Down
3 changes: 3 additions & 0 deletions solution/3200-3299/3280.Convert Date to Binary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README.md
tags:
- 数学
- 字符串
---

<!-- problem:start -->
Expand Down
3 changes: 3 additions & 0 deletions solution/3200-3299/3280.Convert Date to Binary/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README_EN.md
tags:
- Math
- String
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README.md
tags:
- 贪心
- 数组
- 二分查找
- 排序
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README_EN.md
tags:
- Greedy
- Array
- Binary Search
- Sorting
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README.md
tags:
- 贪心
- 数组
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README_EN.md
tags:
- Greedy
- Array
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README.md
tags:
- 位运算
- 广度优先搜索
- 数组
- 数学
- 状态压缩
- 博弈
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README_EN.md
tags:
- Bit Manipulation
- Breadth-First Search
- Array
- Math
- Bitmask
- Game Theory
---

<!-- problem:start -->
Expand Down
14 changes: 7 additions & 7 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@
| 1364 | [顾客的可信联系人数量](/solution/1300-1399/1364.Number%20of%20Trusted%20Contacts%20of%20a%20Customer/README.md) | `数据库` | 中等 | 🔒 |
| 1365 | [有多少小于当前数字的数字](/solution/1300-1399/1365.How%20Many%20Numbers%20Are%20Smaller%20Than%20the%20Current%20Number/README.md) | `数组`,`哈希表`,`计数`,`排序` | 简单 | 第 178 场周赛 |
| 1366 | [通过投票对团队排名](/solution/1300-1399/1366.Rank%20Teams%20by%20Votes/README.md) | `数组`,`哈希表`,`字符串`,`计数`,`排序` | 中等 | 第 178 场周赛 |
| 1367 | [二叉树中的链表](/solution/1300-1399/1367.Linked%20List%20in%20Binary%20Tree/README.md) | `树`,`深度优先搜索`,`广度优先搜索`,`链表`,`二叉树` | 中等 | 第 178 场周赛 |
| 1367 | [二叉树中的链表](/solution/1300-1399/1367.Linked%20List%20in%20Binary%20Tree/README.md) | `树`,`深度优先搜索`,`链表`,`二叉树` | 中等 | 第 178 场周赛 |
| 1368 | [使网格图至少有一条有效路径的最小代价](/solution/1300-1399/1368.Minimum%20Cost%20to%20Make%20at%20Least%20One%20Valid%20Path%20in%20a%20Grid/README.md) | `广度优先搜索`,`图`,`数组`,`矩阵`,`最短路`,`堆(优先队列)` | 困难 | 第 178 场周赛 |
| 1369 | [获取最近第二次的活动](/solution/1300-1399/1369.Get%20the%20Second%20Most%20Recent%20Activity/README.md) | `数据库` | 困难 | 🔒 |
| 1370 | [上升下降字符串](/solution/1300-1399/1370.Increasing%20Decreasing%20String/README.md) | `哈希表`,`字符串`,`计数` | 简单 | 第 21 场双周赛 |
Expand Down Expand Up @@ -2482,7 +2482,7 @@
| 2469 | [温度转换](/solution/2400-2499/2469.Convert%20the%20Temperature/README.md) | `数学` | 简单 | 第 319 场周赛 |
| 2470 | [最小公倍数等于 K 的子数组数目](/solution/2400-2499/2470.Number%20of%20Subarrays%20With%20LCM%20Equal%20to%20K/README.md) | `数组`,`数学`,`数论` | 中等 | 第 319 场周赛 |
| 2471 | [逐层排序二叉树所需的最少操作数目](/solution/2400-2499/2471.Minimum%20Number%20of%20Operations%20to%20Sort%20a%20Binary%20Tree%20by%20Level/README.md) | `树`,`广度优先搜索`,`二叉树` | 中等 | 第 319 场周赛 |
| 2472 | [不重叠回文子字符串的最大数目](/solution/2400-2499/2472.Maximum%20Number%20of%20Non-overlapping%20Palindrome%20Substrings/README.md) | `字符串`,`动态规划` | 困难 | 第 319 场周赛 |
| 2472 | [不重叠回文子字符串的最大数目](/solution/2400-2499/2472.Maximum%20Number%20of%20Non-overlapping%20Palindrome%20Substrings/README.md) | `贪心`,`双指针`,`字符串`,`动态规划` | 困难 | 第 319 场周赛 |
| 2473 | [购买苹果的最低成本](/solution/2400-2499/2473.Minimum%20Cost%20to%20Buy%20Apples/README.md) | `图`,`数组`,`最短路`,`堆(优先队列)` | 中等 | 🔒 |
| 2474 | [购买量严格增加的客户](/solution/2400-2499/2474.Customers%20With%20Strictly%20Increasing%20Purchases/README.md) | `数据库` | 困难 | 🔒 |
| 2475 | [数组中不等三元组的数目](/solution/2400-2499/2475.Number%20of%20Unequal%20Triplets%20in%20Array/README.md) | `数组`,`哈希表`,`排序` | 简单 | 第 320 场周赛 |
Expand Down Expand Up @@ -3289,11 +3289,11 @@
| 3276 | [选择矩阵中单元格的最大得分](/solution/3200-3299/3276.Select%20Cells%20in%20Grid%20With%20Maximum%20Score/README.md) | `位运算`,`数组`,`动态规划`,`状态压缩`,`矩阵` | 困难 | 第 413 场周赛 |
| 3277 | [查询子数组最大异或值](/solution/3200-3299/3277.Maximum%20XOR%20Score%20Subarray%20Queries/README.md) | `数组`,`动态规划` | 困难 | 第 413 场周赛 |
| 3278 | [寻找数据科学家职位的候选人 II](/solution/3200-3299/3278.Find%20Candidates%20for%20Data%20Scientist%20Position%20II/README.md) | `数据库` | 中等 | 🔒 |
| 3279 | [Maximum Total Area Occupied by Pistons](/solution/3200-3299/3279.Maximum%20Total%20Area%20Occupied%20by%20Pistons/README.md) | | 困难 | 🔒 |
| 3280 | [将日期转换为二进制表示](/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README.md) | | 简单 | 第 414 场周赛 |
| 3281 | [范围内整数的最大得分](/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README.md) | | 中等 | 第 414 场周赛 |
| 3282 | [到达数组末尾的最大得分](/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README.md) | | 中等 | 第 414 场周赛 |
| 3283 | [吃掉所有兵需要的最多移动次数](/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README.md) | | 困难 | 第 414 场周赛 |
| 3279 | [Maximum Total Area Occupied by Pistons](/solution/3200-3299/3279.Maximum%20Total%20Area%20Occupied%20by%20Pistons/README.md) | `数组`,`哈希表`,`字符串`,`计数`,`前缀和`,`模拟` | 困难 | 🔒 |
| 3280 | [将日期转换为二进制表示](/solution/3200-3299/3280.Convert%20Date%20to%20Binary/README.md) | `数学`,`字符串` | 简单 | 第 414 场周赛 |
| 3281 | [范围内整数的最大得分](/solution/3200-3299/3281.Maximize%20Score%20of%20Numbers%20in%20Ranges/README.md) | `贪心`,`数组`,`二分查找`,`排序` | 中等 | 第 414 场周赛 |
| 3282 | [到达数组末尾的最大得分](/solution/3200-3299/3282.Reach%20End%20of%20Array%20With%20Max%20Score/README.md) | `贪心`,`数组` | 中等 | 第 414 场周赛 |
| 3283 | [吃掉所有兵需要的最多移动次数](/solution/3200-3299/3283.Maximum%20Number%20of%20Moves%20to%20Kill%20All%20Pawns/README.md) | `位运算`,`广度优先搜索`,`数组`,`数学`,`状态压缩`,`博弈` | 困难 | 第 414 场周赛 |

## 版权

Expand Down
Loading
Loading