Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

feat: add weekly contest 436 #4048

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
Feb 9, 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/0800-0899/0870.Advantage Shuffle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<p>给定两个长度相等的数组&nbsp;<code>nums1</code>&nbsp;和&nbsp;<code>nums2</code>,<code>nums1</code>&nbsp;相对于 <code>nums2</code> 的<em>优势</em>可以用满足&nbsp;<code>nums1[i] &gt; nums2[i]</code>&nbsp;的索引 <code>i</code>&nbsp;的数目来描述。</p>

<p>返回 <font color="#c7254e" face="Menlo, Monaco, Consolas, Courier New, monospace" size="1"><span style="background-color: rgb(249, 242, 244);">nums1</span></font>&nbsp;<strong>任意</strong>排列,使其相对于 <code>nums2</code>&nbsp;的优势最大化。</p>
<p>返回 <code>nums1</code> 的&nbsp;<strong>任意&nbsp;</strong>排列,使其相对于 <code>nums2</code>&nbsp;的优势最大化。</p>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We return true because 21 + 210 == 231.
<pre>
<strong>Input:</strong> firstWord = &quot;aaa&quot;, secondWord = &quot;a&quot;, targetWord = &quot;aab&quot;
<strong>Output:</strong> false
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The numerical value of firstWord is &quot;aaa&quot; -&gt; &quot;000&quot; -&gt; 0.
The numerical value of secondWord is &quot;a&quot; -&gt; &quot;0&quot; -&gt; 0.
The numerical value of targetWord is &quot;aab&quot; -&gt; &quot;001&quot; -&gt; 1.
Expand All @@ -60,7 +60,7 @@ We return false because 0 + 0 != 1.
<pre>
<strong>Input:</strong> firstWord = &quot;aaa&quot;, secondWord = &quot;a&quot;, targetWord = &quot;aaaa&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The numerical value of firstWord is &quot;aaa&quot; -&gt; &quot;000&quot; -&gt; 0.
The numerical value of secondWord is &quot;a&quot; -&gt; &quot;0&quot; -&gt; 0.
The numerical value of targetWord is &quot;aaaa&quot; -&gt; &quot;0000&quot; -&gt; 0.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ tags:
<pre>
<strong>Input:</strong> servers = [5,1,4,3,2], tasks = [2,1,2,4,5,2,1]
<strong>Output:</strong> [1,4,1,4,1,3,2]
<strong>Explanation: </strong>Events in chronological order go as follows:
<strong>Explanation: </strong>Events in chronological order go as follows:
- At second 0, task 0 is added and processed using server 1 until second 2.
- At second 1, task 1 is added and processed using server 4 until second 2.
- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4.
- At second 2, servers 1 and 4 become free. Task 2 is added and processed using server 1 until second 4.
- At second 3, task 3 is added and processed using server 4 until second 7.
- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9.
- At second 4, server 1 becomes free. Task 4 is added and processed using server 1 until second 9.
- At second 5, task 5 is added and processed using server 3 until second 7.
- At second 6, task 6 is added and processed using server 2 until second 7.
</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [0,2,1,5,3,4]
<strong>Output:</strong> [0,1,2,4,5,3]<strong>
Explanation:</strong> The array ans is built as follows:
Explanation:</strong> The array ans is built as follows:
ans = [nums[nums[0]], nums[nums[1]], nums[nums[2]], nums[nums[3]], nums[nums[4]], nums[nums[5]]]
= [nums[0], nums[2], nums[1], nums[5], nums[3], nums[4]]
= [0,1,2,4,5,3]</pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tags:
<pre>
<strong>Input:</strong> times = [[1,4],[2,3],[4,6]], targetFriend = 1
<strong>Output:</strong> 1
<strong>Explanation:</strong>
<strong>Explanation:</strong>
- Friend 0 arrives at time 1 and sits on chair 0.
- Friend 1 arrives at time 2 and sits on chair 1.
- Friend 1 leaves at time 3 and chair 1 becomes empty.
Expand All @@ -52,7 +52,7 @@ Since friend 1 sat on chair 1, we return 1.
<pre>
<strong>Input:</strong> times = [[3,10],[1,5],[2,6]], targetFriend = 0
<strong>Output:</strong> 2
<strong>Explanation:</strong>
<strong>Explanation:</strong>
- Friend 1 arrives at time 1 and sits on chair 0.
- Friend 2 arrives at time 2 and sits on chair 1.
- Friend 0 arrives at time 3 and sits on chair 2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ tags:
- 2 映射为 change[2] = 3 。
- 1 映射为 change[1] = 4 。
因此,"<strong><em>021</em></strong>" 变为 "<strong><em>934</em></strong>" 。
"934" 是可以构造的最大整数,所以返回它的字符串表示。
"934" 是可以构造的最大整数,所以返回它的字符串表示。
</pre>

<p><strong>示例 3:</strong></p>
Expand Down
43 changes: 22 additions & 21 deletions solution/3400-3499/3436.Find Valid Emails/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ tags:

<!-- problem:start -->

# [3436. Find Valid Emails](https://leetcode.cn/problems/find-valid-emails)
# [3436. 查找合法邮箱](https://leetcode.cn/problems/find-valid-emails)

[English Version](/solution/3400-3499/3436.Find%20Valid%20Emails/README_EN.md)

## 题目描述

<!-- description:start -->

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

<pre>
+-----------------+---------+
Expand All @@ -25,28 +25,29 @@ tags:
| user_id | int |
| email | varchar |
+-----------------+---------+
(user_id) is the unique key for this table.
Each row contains a user&#39;s unique ID and email address.
(user_id) 是这张表的唯一主键。
每一行包含用户的唯一 ID 和邮箱地址。
</pre>

<p>Write a solution to find all the <strong>valid email addresses</strong>. A valid email address meets the following criteria:</p>
<p>编写一个解决方案来查找所有 <b>合法邮箱地址</b>。一个合法的邮箱地址符合下述条件:</p>

<ul>
<li>It contains exactly one <code>@</code> symbol.</li>
<li>It ends with <code>.com</code>.</li>
<li>The part before the <code>@</code> symbol contains only <strong>alphanumeric</strong> characters and <strong>underscores</strong>.</li>
<li>The part after the <code>@</code> symbol and before <code>.com</code> contains a domain name <strong>that contains only letters</strong>.</li>
<li>只包含一个&nbsp;<code>@</code>&nbsp;符号。</li>
<li>以&nbsp;<code>.com</code>&nbsp;结尾。</li>
<li><code>@</code>&nbsp;符号前面的部分只包含&nbsp;<strong>字母数字</strong>&nbsp;字符和&nbsp;<strong>下划线</strong></li>
<li><code>@</code>&nbsp;符号后面与&nbsp;<code>.com</code>&nbsp;前面的部分 包含 <strong>只有字母&nbsp;</strong>的域名。</li>
</ul>

<p>Return<em> the result table ordered by</em> <code>user_id</code> <em>in</em> <strong>ascending </strong><em>order</em>.</p>
<p>返回结果表以&nbsp;<code>user_id</code> <strong>升序</strong>&nbsp;排序。</p>

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

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

<div class="example-block">
<p><strong>Input:</strong></p>
<p><strong>输入:</strong></p>

<p>Users table:</p>
<p>Users 表:</p>

<pre class="example-io">
+---------+---------------------+
Expand All @@ -60,7 +61,7 @@ Each row contains a user&#39;s unique ID and email address.
+---------+---------------------+
</pre>

<p><strong>Output:</strong></p>
<p><strong>输出:</strong></p>

<pre class="example-io">
+---------+-------------------+
Expand All @@ -71,17 +72,17 @@ Each row contains a user&#39;s unique ID and email address.
+---------+-------------------+
</pre>

<p><strong>Explanation:</strong></p>
<p><strong>解释:</strong></p>

<ul>
<li><strong>alice@example.com</strong> is valid because it contains one <code>@</code>, alice&nbsp;is alphanumeric, and example.com&nbsp;starts with a letter and ends with .com.</li>
<li><strong>bob_at_example.com</strong> is invalid because it contains an underscore instead of an <code>@</code>.</li>
<li><strong>charlie@example.net</strong> is invalid because the domain does not end with <code>.com</code>.</li>
<li><strong>david@domain.com</strong> is valid because it meets all criteria.</li>
<li><strong>eve@invalid</strong> is invalid because the domain does not end with <code>.com</code>.</li>
<li><strong>alice@example.com</strong>&nbsp;是合法的因为它包含一个&nbsp;<code>@</code>alice 是只有字母数字的,并且&nbsp;example.com 以字母开始并以 .com&nbsp;结束。</li>
<li><strong>bob_at_example.com</strong>&nbsp;是不合法的因为它包含下划线但没有&nbsp;<code>@</code></li>
<li><strong>charlie@example.net</strong>&nbsp;是不合法的因为域名没有以&nbsp;<code>.com</code>&nbsp;结尾。</li>
<li><strong>david@domain.com</strong>&nbsp;是合法的因为它满足所有条件。</li>
<li><strong>eve@invalid</strong>&nbsp;是不合法的因为域名没有以&nbsp;<code>.com</code>&nbsp;结尾。</li>
</ul>

<p>Result table is ordered by user_id in ascending order.</p>
<p>结果表以 user_id 升序排序。</p>
</div>

<!-- description:end -->
Expand Down
28 changes: 15 additions & 13 deletions solution/3400-3499/3437.Permutations III/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,47 @@ tags:

<!-- problem:start -->

# [3437. Permutations III 🔒](https://leetcode.cn/problems/permutations-iii)
# [3437. 全排列 III 🔒](https://leetcode.cn/problems/permutations-iii)

[English Version](/solution/3400-3499/3437.Permutations%20III/README_EN.md)

## 题目描述

<!-- description:start -->

<p>Given an integer <code>n</code>, an <strong>alternating permutation</strong> is a permutation of the first <code>n</code> positive integers such that no <strong>two</strong> adjacent elements are <strong>both</strong> odd or <strong>both</strong> even.</p>
<p>给定一个整数&nbsp;<code>n</code>,一个 <strong>交替排列</strong> 是没有 <strong>两个</strong> 相邻元素 <strong>同时</strong> 为奇数或偶数的前 <code>n</code> 个正整数的排列。</p>

<p>Return <em>all such </em><strong>alternating permutations</strong> sorted in lexicographical order.</p>
<p>返回所有这样的 <strong>交替排列</strong>&nbsp;以字典序排序。</p>

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

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 4</span></p>
<p><span class="example-io"><b>输入:</b>n = 4</span></p>

<p><strong>Output:</strong> <span class="example-io">[[1,2,3,4],[1,4,3,2],[2,1,4,3],[2,3,4,1],[3,2,1,4],[3,4,1,2],[4,1,2,3],[4,3,2,1]]</span></p>
<p><span class="example-io"><b>输出:</b>[[1,2,3,4],[1,4,3,2],[2,1,4,3],[2,3,4,1],[3,2,1,4],[3,4,1,2],[4,1,2,3],[4,3,2,1]]</span></p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 2</span></p>
<p><span class="example-io"><b>输入:</b>n = 2</span></p>

<p><strong>Output:</strong> <span class="example-io">[[1,2],[2,1]]</span></p>
<p><span class="example-io"><b>输出:</b>[[1,2],[2,1]]</span></p>
</div>

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

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 3</span></p>
<p><strong>输入:</strong><span class="example-io">n = 3</span></p>

<p><strong>Output:</strong> <span class="example-io">[[1,2,3],[3,2,1]]</span></p>
<p><span class="example-io"><b>输出:</b>[[1,2,3],[3,2,1]]</span></p>
</div>

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

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

<ul>
<li><code>1 &lt;= n &lt;= 10</code></li>
Expand Down
Loading
Loading