Skip to content
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

feat: update lc problems #2008

Merged
merged 4 commits into from
Nov 24, 2023
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 @@ -17,15 +17,15 @@
| department | varchar |
| managerId | int |
+-------------+---------+
在 SQL 中,id 是该表的主键列
该表的每一行都表示雇员的名字、他们的部门和他们的经理的id。
id 是此表的主键(具有唯一值的列)
该表的每一行表示雇员的名字、他们的部门和他们的经理的id。
如果managerId为空,则该员工没有经理。
没有员工会成为自己的管理者。
</pre>

<p>&nbsp;</p>

<p>查询<strong>至少有5名直接下属</strong>的经理<strong> </strong>。</p>
<p>编写一个解决方案,找出至少有<strong>五个直接下属</strong>的经理。</p>

<p>以 <strong>任意顺序 </strong>返回结果表。</p>

Expand All @@ -41,7 +41,7 @@ Employee 表:
+-----+-------+------------+-----------+
| id | name | department | managerId |
+-----+-------+------------+-----------+
| 101 | John | A | None |
| 101 | John | A | Null |
| 102 | Dan | A | 101 |
| 103 | James | A | 101 |
| 104 | Amy | A | 101 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Employee table:
+-----+-------+------------+-----------+
| id | name | department | managerId |
+-----+-------+------------+-----------+
| 101 | John | A | None |
| 101 | John | A | null |
| 102 | Dan | A | 101 |
| 103 | James | A | 101 |
| 104 | Amy | A | 101 |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<p><strong>提示:</strong></p>

<ul>
<li>数中节点数在&nbsp;<code>[1, 5000]</code>&nbsp;范围内</li>
<li>树中节点数在&nbsp;<code>[1, 5000]</code>&nbsp;范围内</li>
<li><code>1 &lt;= Node.val &lt;= 10<sup>7</sup></code></li>
<li><code>root</code>&nbsp;是二叉搜索树</li>
<li><code>1 &lt;= val &lt;= 10<sup>7</sup></code></li>
Expand Down
2 changes: 2 additions & 0 deletions solution/0800-0899/0815.Bus Routes/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
<strong>Output:</strong> -1
</pre>

<p>&nbsp;</p>

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<p><strong>示例 1:</strong></p>

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1293.Shortest%20Path%20in%20a%20Grid%20with%20Obstacles%20Elimination/images/short1-grid.jpg" /></p>
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1293.Shortest%20Path%20in%20a%20Grid%20with%20Obstacles%20Elimination/images/1700710956-kcxqcC-img_v3_025f_d55a658c-8f40-464b-800f-22ccd27cc9fg.jpg" style="width: 243px; height: 404px;" /></p>

<pre>
<strong>输入:</strong> grid = [[0,0,0],[1,1,0],[0,0,0],[0,1,1],[0,0,0]], k = 1
Expand All @@ -26,7 +26,7 @@

<p><strong>示例 2:</strong></p>

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1293.Shortest%20Path%20in%20a%20Grid%20with%20Obstacles%20Elimination/images/short2-grid.jpg" /></p>
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1200-1299/1293.Shortest%20Path%20in%20a%20Grid%20with%20Obstacles%20Elimination/images/1700710701-uPqkZe-img_v3_025f_0edd50fb-8a70-4a42-add0-f602caaad35g.jpg" style="width: 243px; height: 244px;" /></p>

<pre>
<strong>输入:</strong>grid = [[0,1,1],[1,1,1],[1,0,0]], k = 1
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -49,7 +49,7 @@

<ul>
<li><code>1 &lt;= s.length &lt;= 10<sup>5</sup></code></li>
<li><code>s</code> 由小写字符串组成</li>
<li><code>s</code> 由小写字符串组成</li>
</ul>

## 解法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ One possible way to satisfy the conditions is by doing the following:
1. Rearrange <code>arr</code> so it becomes <code>[1,100,1000]</code>.
2. Decrease the value of the second element to 2.
3. Decrease the value of the third element to 3.
Now <code>arr = [1,2,3], which </code>satisfies the conditions.
Now <code>arr = [1,2,3]</code>, which<code> </code>satisfies the conditions.
The largest element in <code>arr is 3.</code>
</pre>

Expand Down
62 changes: 32 additions & 30 deletions solution/2900-2999/2936.Number of Equal Numbers Blocks/README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,68 @@
# [2936. Number of Equal Numbers Blocks](https://leetcode.cn/problems/number-of-equal-numbers-blocks)
# [2936. 包含相等值数字块的数量](https://leetcode.cn/problems/number-of-equal-numbers-blocks)

[English Version](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md)

## 题目描述

<!-- 这里写题目描述 -->

<p>You are given a <strong>0-indexed</strong> array of integers, <code>nums</code>. The following property holds for <code>nums</code>:</p>
<p>给定一个整数数组 <code>nums</code>,其&nbsp;<strong>下标从 0 开始</strong>。对于 <code>nums</code>,有以下性质:</p>

<ul>
<li>All occurrences of a value are adjacent. In other words, if there are two indices <code>i &lt; j</code> such that <code>nums[i] == nums[j]</code>, then for every index <code>k</code> that <code>i &lt; k &lt; j</code>, <code>nums[k] == nums[i]</code>.</li>
<li>所有相同值的元素都是相邻的。换句话说,如果存在两个下标 <code>i &lt; j</code>,使得 <code>nums[i] == nums[j]</code>,那么对于所有下标 <code>k</code>,满足 <code>i &lt; k &lt; j</code>,都有 <code>nums[k] == nums[i]</code></li>
</ul>

<p>Since <code>nums</code> is a very large array, you are given an instance of the class <code>BigArray</code> which has the following functions:</p>
<p>由于 <code>nums</code> 是一个非常大的数组,这里提供了一个 <code>BigArray</code> 类的实例,该实例具有以下函数:</p>

<ul>
<li><code>int at(long long index)</code>: Returns the value of <code>nums[i]</code>.</li>
<li><code>void size()</code>: Returns <code>nums.length</code>.</li>
<li><code>int at(long long index)</code>: 返回 <code>nums[i]</code> 的值。</li>
<li><code>void size()</code>: 返回 <code>nums.length</code></li>
</ul>

<p>Let&#39;s partition the array into <strong>maximal</strong> blocks such that each block contains <strong>equal values</strong>. Return<em> the number of these blocks.</em></p>
<p>让我们把数组分成 <strong>最大</strong>&nbsp;的块,使得每个块包含 <strong>相等的值</strong>。返回这些块的数量。</p>

<p><strong>Note</strong> that if you want to test your solution using a custom test, behavior for tests with <code>nums.length &gt; 10</code> is undefined.</p>
<p><strong>请注意</strong>,如果要使用自定义测试测试解决方案,对于 <code>nums.length &gt; 10</code> 的测试行为是未定义的。</p>

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

<p><strong>示例 1:</strong></p>

<pre>
<strong>Input:</strong> nums = [3,3,3,3,3]
<strong>Output:</strong> 1
<strong>Explanation:</strong> There is only one block here which is the whole array (because all numbers are equal) and that is: [<u>3,3,3,3,3</u>]. So the answer would be 1.
<b>输入:</b>nums = [3,3,3,3,3]
<b>输出:</b>1
<b>解释:</b>这里只有一个块,即整个数组(因为所有数字都相等),即:[3,3,3,3,3]。因此答案是 1。
</pre>

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

<pre>
<strong>Input:</strong> nums = [1,1,1,3,9,9,9,2,10,10]
<strong>Output:</strong> 5
<strong>Explanation:</strong> There are 5 blocks here:
Block number 1: [<u>1,1,1</u>,3,9,9,9,2,10,10]
Block number 2: [1,1,1,<u>3</u>,9,9,9,2,10,10]
Block number 3: [1,1,1,3,<u>9,9,9</u>,2,10,10]
Block number 4: [1,1,1,3,9,9,9,<u>2</u>,10,10]
Block number 5: [1,1,1,3,9,9,9,2,<u>10,10</u>]
So the answer would be 5.</pre>

<p><strong class="example">Example 3:</strong></p>
<b>输入:</b>nums = [1,1,1,3,9,9,9,2,10,10]
<b>输出:</b>5
<b>解释:</b>这里有 5 个块:
块号 1: [<u>1,1,1</u>,3,9,9,9,2,10,10]
块号 2: [1,1,1,<u>3</u>,9,9,9,2,10,10]
块号 3: [1,1,1,3,<u>9,9,9</u>,2,10,10]
块号 4: [1,1,1,3,9,9,9,<u>2</u>,10,10]
块号 5: [1,1,1,3,9,9,9,2,<u>10,10</u>]
因此答案是 5。</pre>

<p><strong class="example">示例 3:</strong></p>

<pre>
<strong>Input:</strong> nums = [1,2,3,4,5,6,7]
<strong>Output:</strong> 7
<strong>Explanation:</strong> Since all numbers are distinct, there are 7 blocks here and each element representing one block. So the answer would be 7.
<b>输入:</b>nums = [1,2,3,4,5,6,7]
<b>输出:</b>7
<b>解释:</b>由于所有数字都是不同的,这里有 7 个块,每个元素代表一个块。因此答案是 7。
</pre>

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

<p><strong>提示:</strong></p>

<ul>
<li><code>1 &lt;= nums.length &lt;= 10<sup>15</sup></code></li>
<li><code>1 &lt;= nums[i] &lt;= 10<sup>9</sup></code></li>
<li>The input is generated such that all equal values are adjacent.</li>
<li>The sum of the elements of&nbsp;<code>nums</code>&nbsp;is at most&nbsp;<code>10<sup>15</sup></code>.</li>
<li>在生成的输入中所有相同值的元素是相邻的。</li>
<li><code>nums</code> 的所有元素之和最多为<meta charset="UTF-8" />&nbsp;<code>10<sup>15</sup></code></li>
</ul>

## 解法
Expand Down
2 changes: 1 addition & 1 deletion solution/CONTEST_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
- [2780. 合法分割的最小下标](/solution/2700-2799/2780.Minimum%20Index%20of%20a%20Valid%20Split/README.md)
- [2781. 最长合法子字符串的长度](/solution/2700-2799/2781.Length%20of%20the%20Longest%20Valid%20Substring/README.md)

#### 第 353 场周赛(2023-07-09 10:30, 90 分钟) 参赛人数 4112
#### 第 353 场周赛(2023-07-09 10:30, 90 分钟) 参赛人数 4113

- [2769. 找出最大的可达成数字](/solution/2700-2799/2769.Find%20the%20Maximum%20Achievable%20Number/README.md)
- [2770. 达到末尾下标所需的最大跳跃次数](/solution/2700-2799/2770.Maximum%20Number%20of%20Jumps%20to%20Reach%20the%20Last%20Index/README.md)
Expand Down
10 changes: 5 additions & 5 deletions solution/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2946,11 +2946,11 @@
| 2933 | [高访问员工](/solution/2900-2999/2933.High-Access%20Employees/README.md) | `数组`,`哈希表`,`字符串`,`排序` | 中等 | 第 371 场周赛 |
| 2934 | [最大化数组末位元素的最少操作次数](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README.md) | `贪心`,`数组` | 中等 | 第 371 场周赛 |
| 2935 | [找出强数对的最大异或值 II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README.md) | `位运算`,`字典树`,`数组`,`哈希表`,`滑动窗口` | 困难 | 第 371 场周赛 |
| 2936 | [包含相等值数字块的数量](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README.md) | | 中等 | 🔒 |
| 2937 | [使三个字符串相等](/solution/2900-2999/2937.Make%20Three%20Strings%20Equal/README.md) | | 简单 | 第 372 场周赛 |
| 2938 | [区分黑球与白球](/solution/2900-2999/2938.Separate%20Black%20and%20White%20Balls/README.md) | | 中等 | 第 372 场周赛 |
| 2939 | [最大异或乘积](/solution/2900-2999/2939.Maximum%20Xor%20Product/README.md) | | 中等 | 第 372 场周赛 |
| 2940 | [找到 Alice 和 Bob 可以相遇的建筑](/solution/2900-2999/2940.Find%20Building%20Where%20Alice%20and%20Bob%20Can%20Meet/README.md) | | 困难 | 第 372 场周赛 |
| 2936 | [包含相等值数字块的数量](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README.md) | `数组`,`二分查找`,`分治` | 中等 | 🔒 |
| 2937 | [使三个字符串相等](/solution/2900-2999/2937.Make%20Three%20Strings%20Equal/README.md) | `字符串` | 简单 | 第 372 场周赛 |
| 2938 | [区分黑球与白球](/solution/2900-2999/2938.Separate%20Black%20and%20White%20Balls/README.md) | `贪心`,`双指针`,`字符串` | 中等 | 第 372 场周赛 |
| 2939 | [最大异或乘积](/solution/2900-2999/2939.Maximum%20Xor%20Product/README.md) | `贪心`,`位运算`,`数学` | 中等 | 第 372 场周赛 |
| 2940 | [找到 Alice 和 Bob 可以相遇的建筑](/solution/2900-2999/2940.Find%20Building%20Where%20Alice%20and%20Bob%20Can%20Meet/README.md) | `栈`,`树状数组`,`线段树`,`数组`,`二分查找`,`单调栈`,`堆(优先队列)` | 困难 | 第 372 场周赛 |
| 2941 | [Maximum GCD-Sum of a Subarray](/solution/2900-2999/2941.Maximum%20GCD-Sum%20of%20a%20Subarray/README.md) | | 困难 | 🔒 |

## 版权
Expand Down
10 changes: 5 additions & 5 deletions solution/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2944,11 +2944,11 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
| 2933 | [High-Access Employees](/solution/2900-2999/2933.High-Access%20Employees/README_EN.md) | `Array`,`Hash Table`,`String`,`Sorting` | Medium | Weekly Contest 371 |
| 2934 | [Minimum Operations to Maximize Last Elements in Arrays](/solution/2900-2999/2934.Minimum%20Operations%20to%20Maximize%20Last%20Elements%20in%20Arrays/README_EN.md) | `Greedy`,`Array` | Medium | Weekly Contest 371 |
| 2935 | [Maximum Strong Pair XOR II](/solution/2900-2999/2935.Maximum%20Strong%20Pair%20XOR%20II/README_EN.md) | `Bit Manipulation`,`Trie`,`Array`,`Hash Table`,`Sliding Window` | Hard | Weekly Contest 371 |
| 2936 | [Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md) | | Medium | 🔒 |
| 2937 | [Make Three Strings Equal](/solution/2900-2999/2937.Make%20Three%20Strings%20Equal/README_EN.md) | | Easy | Weekly Contest 372 |
| 2938 | [Separate Black and White Balls](/solution/2900-2999/2938.Separate%20Black%20and%20White%20Balls/README_EN.md) | | Medium | Weekly Contest 372 |
| 2939 | [Maximum Xor Product](/solution/2900-2999/2939.Maximum%20Xor%20Product/README_EN.md) | | Medium | Weekly Contest 372 |
| 2940 | [Find Building Where Alice and Bob Can Meet](/solution/2900-2999/2940.Find%20Building%20Where%20Alice%20and%20Bob%20Can%20Meet/README_EN.md) | | Hard | Weekly Contest 372 |
| 2936 | [Number of Equal Numbers Blocks](/solution/2900-2999/2936.Number%20of%20Equal%20Numbers%20Blocks/README_EN.md) | `Array`,`Binary Search`,`Divide and Conquer` | Medium | 🔒 |
| 2937 | [Make Three Strings Equal](/solution/2900-2999/2937.Make%20Three%20Strings%20Equal/README_EN.md) | `String` | Easy | Weekly Contest 372 |
| 2938 | [Separate Black and White Balls](/solution/2900-2999/2938.Separate%20Black%20and%20White%20Balls/README_EN.md) | `Greedy`,`Two Pointers`,`String` | Medium | Weekly Contest 372 |
| 2939 | [Maximum Xor Product](/solution/2900-2999/2939.Maximum%20Xor%20Product/README_EN.md) | `Greedy`,`Bit Manipulation`,`Math` | Medium | Weekly Contest 372 |
| 2940 | [Find Building Where Alice and Bob Can Meet](/solution/2900-2999/2940.Find%20Building%20Where%20Alice%20and%20Bob%20Can%20Meet/README_EN.md) | `Stack`,`Binary Indexed Tree`,`Segment Tree`,`Array`,`Binary Search`,`Monotonic Stack`,`Heap (Priority Queue)` | Hard | Weekly Contest 372 |
| 2941 | [Maximum GCD-Sum of a Subarray](/solution/2900-2999/2941.Maximum%20GCD-Sum%20of%20a%20Subarray/README_EN.md) | | Hard | 🔒 |

## Copyright
Expand Down
4 changes: 2 additions & 2 deletions solution/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,14 @@ def run():
if slug:
question_details[slug] = item

for q in spider.get_all_questions(retry=4):
for q in spider.get_all_questions(retry=6):
slug = q["stat"]["question__title_slug"]
qid = q["stat"]["frontend_question_id"]
if slug in question_details:
continue
detail = spider.get_question_detail(
slug, retry=4
) or spider.get_question_detail_en(slug, retry=4)
) or spider.get_question_detail_en(slug, retry=8)
if not detail:
continue
time.sleep(0.3)
Expand Down