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: add weekly contest #3926

Merged
merged 1 commit into from
Jan 5, 2025
Merged
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
1 change: 1 addition & 0 deletions solution/0000-0099/0079.Word Search/README.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0079.Word%20Search/README.md
tags:
- 深度优先搜索
- 数组
- 字符串
- 回溯
1 change: 1 addition & 0 deletions solution/0000-0099/0079.Word Search/README_EN.md
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0000-0099/0079.Word%20Search/README_EN.md
tags:
- Depth-First Search
- Array
- String
- Backtracking
4 changes: 2 additions & 2 deletions solution/0100-0199/0151.Reverse Words in a String/README.md
Original file line number Diff line number Diff line change
@@ -30,8 +30,8 @@ tags:
<p><strong>示例 1:</strong></p>

<pre>
<strong>输入:</strong>s = "<code>the sky is blue</code>"
<strong>输出:</strong>"<code>blue is sky the</code>"
<strong>输入:</strong>s = "the sky is blue"
<strong>输出:</strong>"blue is sky the"
</pre>

<p><strong>示例 2:</strong></p>
Original file line number Diff line number Diff line change
@@ -45,7 +45,7 @@ tags:
<pre>
<strong>输入:</strong>nums = [4,5,6,7,0,1,2]
<strong>输出:</strong>0
<strong>解释:</strong>原数组为 [0,1,2,4,5,6,7] ,旋转 3 次得到输入数组。
<strong>解释:</strong>原数组为 [0,1,2,4,5,6,7] ,旋转 4 次得到输入数组。
</pre>

<p><strong>示例 3:</strong></p>
Original file line number Diff line number Diff line change
@@ -104,6 +104,14 @@ Department 表:
- 山姆的薪水第二高
- 没有第三高的工资,因为只有两名员工</pre>

<p>&nbsp;</p>

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

<ul>
<li>没有姓名、薪资和部门 <strong>完全</strong> 相同的员工。</li>
</ul>

<!-- description:end -->

## 解法
Original file line number Diff line number Diff line change
@@ -104,6 +104,13 @@ In the Sales department:
- There is no third-highest salary as there are only two employees
</pre>

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

<ul>
<li>There are no employees with the <strong>exact</strong> same name, salary <em>and</em> department.</li>
</ul>

<!-- description:end -->

## Solutions
4 changes: 2 additions & 2 deletions solution/0200-0299/0207.Course Schedule/README_EN.md
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ tags:
<pre>
<strong>Input:</strong> numCourses = 2, prerequisites = [[1,0]]
<strong>Output:</strong> true
<strong>Explanation:</strong> There are a total of 2 courses to take.
<strong>Explanation:</strong> There are a total of 2 courses to take.
To take course 1 you should have finished course 0. So it is possible.
</pre>

@@ -42,7 +42,7 @@ To take course 1 you should have finished course 0. So it is possible.
<pre>
<strong>Input:</strong> numCourses = 2, prerequisites = [[1,0],[0,1]]
<strong>Output:</strong> false
<strong>Explanation:</strong> There are a total of 2 courses to take.
<strong>Explanation:</strong> There are a total of 2 courses to take.
To take course 1 you should have finished course 0, and to take course 0 you should also have finished course 1. So it is impossible.
</pre>

Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ tags:

<p>你可以总是假设给定的表达式是有效的,并且只包含数字,&nbsp;<code>'?'</code>&nbsp;,&nbsp;&nbsp;<code>':'</code>&nbsp;,&nbsp;&nbsp;<code>'T'</code>&nbsp;和 <code>'F'</code> ,其中 <code>'T'</code> 为真, <code>'F'</code> 为假。表达式中的所有数字都是 <strong>一位</strong> 数(即在 <strong>[0,9] </strong>范围内)。</p>

<p>条件表达式从右到左分组(大多数语言中都是这样),表达式的结果总是为数字 <code>'T'</code> 或 <code>'F'</code> 。</p>
<p>条件表达式从右到左分组(大多数语言中都是这样),表达式的结果总是为数字<code>'T'</code> 或 <code>'F'</code> 。</p>

<p>&nbsp;</p>

Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ tags:
<ul>
<li><code>0 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
<li>输入字符串中只包含&nbsp;<code>'('</code>, <code>')'</code>, <code>'-'</code>&nbsp;和&nbsp;<code>'0'</code> ~ <code>'9'</code>&nbsp;</li>
<li>空树由&nbsp;<code>""</code>&nbsp;而非<code>"()"</code>表示。</li>
<li>树中所有数字的值 <strong>最多</strong> 不超过&nbsp;<code>2<sup>30</sup></code>。</li>
</ul>

<!-- description:end -->
Original file line number Diff line number Diff line change
@@ -54,6 +54,7 @@ tags:
<ul>
<li><code>0 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>s</code> consists of digits, <code>&#39;(&#39;</code>, <code>&#39;)&#39;</code>, and <code>&#39;-&#39;</code> only.</li>
<li>All numbers in the tree have value <strong>at most</strong> than <code>2<sup>30</sup></code>.</li>
</ul>

<!-- description:end -->
5 changes: 4 additions & 1 deletion solution/0500-0599/0542.01 Matrix/README_EN.md
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ tags:

<p>Given an <code>m x n</code> binary matrix <code>mat</code>, return <em>the distance of the nearest </em><code>0</code><em> for each cell</em>.</p>

<p>The distance between two adjacent cells is <code>1</code>.</p>
<p>The distance between two cells sharing a common edge is <code>1</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
@@ -50,6 +50,9 @@ tags:
<li>There is at least one <code>0</code> in <code>mat</code>.</li>
</ul>

<p>&nbsp;</p>
<p><strong>Note:</strong> This question is the same as 1765: <a href="https://leetcode.com/problems/map-of-highest-peak/description/" target="_blank">https://leetcode.com/problems/map-of-highest-peak/</a></p>

<!-- description:end -->

## Solutions
14 changes: 7 additions & 7 deletions solution/0600-0699/0649.Dota2 Senate/README_EN.md
Original file line number Diff line number Diff line change
@@ -39,9 +39,9 @@ tags:
<pre>
<strong>Input:</strong> senate = &quot;RD&quot;
<strong>Output:</strong> &quot;Radiant&quot;
<strong>Explanation:</strong>
The first senator comes from Radiant and he can just ban the next senator&#39;s right in round 1.
And the second senator can&#39;t exercise any rights anymore since his right has been banned.
<strong>Explanation:</strong>
The first senator comes from Radiant and he can just ban the next senator&#39;s right in round 1.
And the second senator can&#39;t exercise any rights anymore since his right has been banned.
And in round 2, the first senator can just announce the victory since he is the only guy in the senate who can vote.
</pre>

@@ -50,10 +50,10 @@ And in round 2, the first senator can just announce the victory since he is the
<pre>
<strong>Input:</strong> senate = &quot;RDD&quot;
<strong>Output:</strong> &quot;Dire&quot;
<strong>Explanation:</strong>
The first senator comes from Radiant and he can just ban the next senator&#39;s right in round 1.
And the second senator can&#39;t exercise any rights anymore since his right has been banned.
And the third senator comes from Dire and he can ban the first senator&#39;s right in round 1.
<strong>Explanation:</strong>
The first senator comes from Radiant and he can just ban the next senator&#39;s right in round 1.
And the second senator can&#39;t exercise any rights anymore since his right has been banned.
And the third senator comes from Dire and he can ban the first senator&#39;s right in round 1.
And in round 2, the third senator can just announce the victory since he is the only guy in the senate who can vote.
</pre>

Original file line number Diff line number Diff line change
@@ -17,22 +17,22 @@ tags:

<!-- description:start -->

<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,找出三个长度为 <code>k</code> 、互不重叠、且全部数字和(<code>3 * k</code> 项)最大的子数组,并返回这三个子数组。</p>
<p>给你一个整数数组 <code>nums</code> 和一个整数 <code>k</code> ,找出三个长度为 <code>k</code> 、互不重叠、且全部数字和最大的子数组,并返回这三个子数组。</p>

<p>以下标的数组形式返回结果,数组中的每一项分别指示每个子数组的起始位置(下标从 <strong>0</strong> 开始)。如果有多个结果,返回字典序最小的一个。</p>

<p>&nbsp;</p>

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

<pre>
<strong>输入:</strong>nums = [1,2,1,2,6,7,5,1], k = 2
<strong>输出:</strong>[0,3,5]
<strong>解释:</strong>子数组 [1, 2], [2, 6], [7, 5] 对应的起始下标为 [0, 3, 5]。
也可以取 [2, 1], 但是结果 [1, 3, 5] 在字典序上更大
也可以取 [2, 1], 但是结果 [1, 3, 5] 在字典序上更小
</pre>

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

<pre>
<strong>输入:</strong>nums = [1,2,1,2,1,2,1,2,1], k = 2
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ tags:
<strong>Input:</strong> nums = [1,2,1,2,6,7,5,1], k = 2
<strong>Output:</strong> [0,3,5]
<strong>Explanation:</strong> Subarrays [1, 2], [2, 6], [7, 5] correspond to the starting indices [0, 3, 5].
We could have also taken [2, 1], but an answer of [1, 3, 5] would be lexicographically larger.
We could have also taken [2, 1], but an answer of [1, 3, 5] would be lexicographically smaller.
</pre>

<p><strong class="example">Example 2:</strong></p>
6 changes: 3 additions & 3 deletions solution/0700-0799/0731.My Calendar II/README_EN.md
Original file line number Diff line number Diff line change
@@ -46,9 +46,9 @@ tags:

<strong>Explanation</strong>
MyCalendarTwo myCalendarTwo = new MyCalendarTwo();
myCalendarTwo.book(10, 20); // return True, The event can be booked.
myCalendarTwo.book(50, 60); // return True, The event can be booked.
myCalendarTwo.book(10, 40); // return True, The event can be double booked.
myCalendarTwo.book(10, 20); // return True, The event can be booked.
myCalendarTwo.book(50, 60); // return True, The event can be booked.
myCalendarTwo.book(10, 40); // return True, The event can be double booked.
myCalendarTwo.book(5, 15); // return False, The event cannot be booked, because it would result in a triple booking.
myCalendarTwo.book(5, 10); // return True, The event can be booked, as it does not use time 10 which is already double booked.
myCalendarTwo.book(25, 55); // return True, The event can be booked, as the time in [25, 40) will be double booked with the third event, the time [40, 50) will be single booked, and the time [50, 55) will be double booked with the second event.
3 changes: 3 additions & 0 deletions solution/0800-0899/0850.Rectangle Area II/README.md
Original file line number Diff line number Diff line change
@@ -55,6 +55,9 @@ tags:
<li><code>1 &lt;= rectangles.length &lt;= 200</code></li>
<li><code>rectanges[i].length = 4</code><meta charset="UTF-8" /></li>
<li><code>0 &lt;= x<sub>i1</sub>, y<sub>i1</sub>, x<sub>i2</sub>, y<sub>i2</sub>&nbsp;&lt;= 10<sup>9</sup></code></li>
<li><code>x<sub>i1&nbsp;</sub>&lt;= x<sub>i2</sub></code></li>
<li><code>y<sub>i1&nbsp;</sub>&lt;= y<sub>i2</sub></code></li>
<li>所有矩阵面积不为 0。</li>
</ul>

<!-- description:end -->
1 change: 1 addition & 0 deletions solution/0800-0899/0850.Rectangle Area II/README_EN.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ From (1,0) to (2,3), all three rectangles overlap.
<li><code>0 &lt;= x<sub>i1</sub>, y<sub>i1</sub>, x<sub>i2</sub>, y<sub>i2</sub> &lt;= 10<sup>9</sup></code></li>
<li><code>x<sub>i1 &lt;= </sub>x<sub>i2</sub></code></li>
<li><code>y<sub>i1 &lt;=</sub> y<sub>i2</sub></code></li>
<li>All rectangles have non zero area.</li>
</ul>

<!-- description:end -->
1 change: 1 addition & 0 deletions solution/0900-0999/0962.Maximum Width Ramp/README.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0962.Ma
tags:
- 栈
- 数组
- 双指针
- 单调栈
---

1 change: 1 addition & 0 deletions solution/0900-0999/0962.Maximum Width Ramp/README_EN.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0962.Ma
tags:
- Stack
- Array
- Two Pointers
- Monotonic Stack
---

Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0986.In
tags:
- 数组
- 双指针
- 扫描线
---

<!-- problem:start -->
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0900-0999/0986.In
tags:
- Array
- Two Pointers
- Line Sweep
---

<!-- problem:start -->
Original file line number Diff line number Diff line change
@@ -32,7 +32,7 @@ tags:
<pre>
<strong>Input:</strong> root = [5,6,1]
<strong>Output:</strong> 6.00000
<strong>Explanation:</strong>
<strong>Explanation:</strong>
For the node with value = 5 we have an average of (5 + 6 + 1) / 3 = 4.
For the node with value = 6 we have an average of 6 / 1 = 6.
For the node with value = 1 we have an average of 1 / 1 = 1.
1 change: 1 addition & 0 deletions solution/1700-1799/1765.Map of Highest Peak/README.md
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@ tags:
<li><code>isWater[i][j]</code>&nbsp;要么是&nbsp;<code>0</code>&nbsp;,要么是&nbsp;<code>1</code>&nbsp;。</li>
<li>至少有 <strong>1</strong>&nbsp;个水域格子。</li>
</ul>
<strong>注意:</strong>本题与 <a href="https://leetcode.cn/problems/01-matrix/">542</a> 题相同。

<!-- description:end -->

3 changes: 3 additions & 0 deletions solution/1700-1799/1765.Map of Highest Peak/README_EN.md
Original file line number Diff line number Diff line change
@@ -73,6 +73,9 @@ Any height assignment that has a maximum height of 2 while still meeting the rul
<li>There is at least <strong>one</strong> water cell.</li>
</ul>

<p>&nbsp;</p>
<p><strong>Note:</strong> This question is the same as 542: <a href="https://leetcode.com/problems/01-matrix/description/" target="_blank">https://leetcode.com/problems/01-matrix/</a></p>

<!-- description:end -->

## Solutions
Original file line number Diff line number Diff line change
@@ -37,9 +37,9 @@ tags:
<pre>
<strong>Input:</strong> low = 3, high = 3, zero = 1, one = 1
<strong>Output:</strong> 8
<strong>Explanation:</strong>
One possible valid good string is &quot;011&quot;.
It can be constructed as follows: &quot;&quot; -&gt; &quot;0&quot; -&gt; &quot;01&quot; -&gt; &quot;011&quot;.
<strong>Explanation:</strong>
One possible valid good string is &quot;011&quot;.
It can be constructed as follows: &quot;&quot; -&gt; &quot;0&quot; -&gt; &quot;01&quot; -&gt; &quot;011&quot;.
All binary strings from &quot;000&quot; to &quot;111&quot; are good strings in this example.
</pre>

Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ tags:

<!-- description:start -->

<p>给你一个字符串 <code>s</code> ,请你判断字符串 <code>s</code> 是否存在一个长度为 <code>2</code> 的子字符串,在其反转后的字符串中也出现。</p>
<p>给你一个字符串 <code>s</code> ,请你判断字符串 <code>s</code> 是否存在一个长度为 <code>2</code> 的子字符串,在 <code>s</code> 反转后的字符串中也出现。</p>

<p>如果存在这样的子字符串,返回 <code>true</code>;如果不存在,返回 <code>false</code> 。</p>

Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README.md
rating: 1235
source: 第 143 场双周赛 Q1
tags:
- 数学
- 枚举
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3345.Smallest%20Divisible%20Digit%20Product%20I/README_EN.md
rating: 1235
source: Biweekly Contest 143 Q1
tags:
- Math
- Enumeration
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README.md
rating: 1864
source: 第 143 场双周赛 Q2
tags:
- 数组
- 二分查找
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3346.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20I/README_EN.md
rating: 1864
source: Biweekly Contest 143 Q2
tags:
- Array
- Binary Search
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README.md
rating: 2155
source: 第 143 场双周赛 Q3
tags:
- 数组
- 二分查找
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3347.Maximum%20Frequency%20of%20an%20Element%20After%20Performing%20Operations%20II/README_EN.md
rating: 2155
source: Biweekly Contest 143 Q3
tags:
- Array
- Binary Search
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README.md
rating: 3101
source: 第 143 场双周赛 Q4
tags:
- 贪心
- 数学
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3348.Smallest%20Divisible%20Digit%20Product%20II/README_EN.md
rating: 3101
source: Biweekly Contest 143 Q4
tags:
- Greedy
- Math
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README.md
rating: 1298
source: 第 423 场周赛 Q1
tags:
- 数组
---
Original file line number Diff line number Diff line change
@@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3349.Adjacent%20Increasing%20Subarrays%20Detection%20I/README_EN.md
rating: 1298
source: Weekly Contest 423 Q1
tags:
- Array
---
Loading
Loading