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

chore: update lc problems #1795

Merged
merged 1 commit into from
Oct 13, 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
2 changes: 1 addition & 1 deletion solution/0000-0099/0074.Search a 2D Matrix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<p>给你一个满足下述两条属性的 <code>m x n</code> 整数矩阵:</p>

<ul>
<li>每行中的整数从左到右按非递减顺序排列。</li>
<li>每行中的整数从左到右按非严格递增顺序排列。</li>
<li>每行的第一个整数大于前一行的最后一个整数。</li>
</ul>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
<li><code>Node.random</code>&nbsp;为&nbsp;<code>null</code> 或指向链表中的节点。</li>
</ul>

<p>注意:本题与主站 138 题相同:<a href="https://leetcode.cn/problems/copy-list-with-random-pointer/" rel="noopener noreferrer" target="_blank">https://leetcode.cn/problems/copy-list-with-random-pointer/</a></p>

<p>&nbsp;</p>

## 解法
Expand Down
2 changes: 1 addition & 1 deletion solution/0600-0699/0683.K Empty Slots/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<p><code>n</code>&nbsp;个灯泡排成一行,编号从 <code>1</code> 到<meta charset="UTF-8" />&nbsp;<code>n</code>&nbsp;。最初,所有灯泡都关闭。每天&nbsp;<strong>只打开一个</strong>&nbsp;灯泡,直到<meta charset="UTF-8" />&nbsp;<code>n</code>&nbsp;天后所有灯泡都打开。</p>

<p>给你一个长度为<meta charset="UTF-8" />&nbsp;<code>n</code>&nbsp;的灯泡数组 <code>blubs</code> ,其中 <code>bulls[i] = x</code> 意味着在第 <code>(i+1)</code> 天,我们会把在位置 <code>x</code> 的灯泡打开,其中 <code>i</code> <strong>从 0 开始</strong>,<code>x</code> <strong>从 1 开始</strong>。</p>
<p>给你一个长度为<meta charset="UTF-8" />&nbsp;<code>n</code>&nbsp;的灯泡数组 <code>blubs</code> ,其中 <code>bulbs[i] = x</code> 意味着在第 <code>(i+1)</code> 天,我们会把在位置 <code>x</code> 的灯泡打开,其中 <code>i</code> <strong>从 0 开始</strong>,<code>x</code> <strong>从 1 开始</strong>。</p>

<p>给你一个整数<meta charset="UTF-8" />&nbsp;<code>k</code>&nbsp;,请返回<em>恰好有两个打开的灯泡,且它们中间 <strong>正好</strong> 有<meta charset="UTF-8" />&nbsp;<code>k</code>&nbsp;个&nbsp;<strong>全部关闭的</strong> 灯泡的 <strong>最小的天数</strong> </em>。<em>如果不存在这种情况,返回 <code>-1</code> 。</em></p>

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

<ul>
<li><code>TimeMap()</code> Initializes the object of the data structure.</li>
<li><code>void set(String key, String value, int timestamp)</code> Stores the key <code>key</code> with the value <code>value </code>at the given time <code>timestamp</code>.</li>
<li><code>void set(String key, String value, int timestamp)</code> Stores the key <code>key</code> with the value <code>value</code> at the given time <code>timestamp</code>.</li>
<li><code>String get(String key, int timestamp)</code> Returns a value such that <code>set</code> was called previously, with <code>timestamp_prev &lt;= timestamp</code>. If there are multiple such values, it returns the value associated with the largest <code>timestamp_prev</code>. If there are no values, it returns <code>&quot;&quot;</code>.</li>
</ul>

Expand Down
4 changes: 2 additions & 2 deletions solution/1100-1199/1159.Market Analysis II/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ item_id is the primary key (column with unique values) of this table.

<p>&nbsp;</p>

<p>Write a solution to find for each user whether the brand of the second item (by date) they sold is their favorite brand. If a user sold less than two items, report the answer for that user as no. It is guaranteed that no seller sold more than one item in a day.</p>
<p>Write a solution&nbsp;to find for each user, the join date and the number of orders they made as a buyer in <code>2019</code>.</p>

<p>Return the result table in <strong>any order</strong>.</p>

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

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p>Given a <code>m&nbsp;* n</code>&nbsp;matrix <code>seats</code>&nbsp;&nbsp;that represent seats distributions&nbsp;in a classroom.&nbsp;If a seat&nbsp;is&nbsp;broken, it is denoted by <code>&#39;#&#39;</code> character otherwise it is denoted by a <code>&#39;.&#39;</code> character.</p>

<p>Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting&nbsp;directly in front or behind him. Return the <strong>maximum </strong>number of students that can take the exam together&nbsp;without any cheating being possible..</p>
<p>Students can see the answers of those sitting next to the left, right, upper left and upper right, but he cannot see the answers of the student sitting&nbsp;directly in front or behind him. Return the <strong>maximum </strong>number of students that can take the exam together&nbsp;without any cheating being possible.</p>

<p>Students must be placed in seats in good condition.</p>

Expand Down
29 changes: 16 additions & 13 deletions solution/1400-1499/1409.Queries on a Permutation With Key/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,38 +6,41 @@

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

<p>给你一个待查数组 <code>queries</code> ,数组中的元素为 <code>1</code> 到 <code>m</code> 之间的正整数。 请你根据以下规则处理所有待查项 <code>queries[i]</code>(从 <code>i=0</code> 到 <code>i=queries.length-1</code>):</p>
<p>给定一个正整数数组&nbsp;<code>queries</code> ,其取值范围在&nbsp;<code>1</code> 到 <code>m</code> 之间。 请你根据以下规则按顺序处理所有&nbsp;<code>queries[i]</code>(从 <code>i=0</code> 到 <code>i=queries.length-1</code>):</p>

<ul>
<li>一开始,排列 <code>P=[1,2,3,...,m]</code>。</li>
<li>对于当前的 <code>i</code> ,请你找出待查项 <code>queries[i]</code> 在排列 <code>P</code> 中的位置(<strong>下标从 0 开始</strong>),然后将其从原位置移动到排列 <code>P</code> 的起始位置(即下标为 0 处)。注意, <code>queries[i]</code><code>P</code> 中的位置就是 <code>queries[i]</code> 的查询结果。</li>
<li>首先,你有一个排列&nbsp;<code>P=[1,2,3,...,m]</code>。</li>
<li>对于当前的 <code>i</code> ,找到&nbsp;<code>queries[i]</code> 在排列 <code>P</code> 中的位置(<b>从 0 开始索引</b>),然后将它移到排列&nbsp;<code>P</code> 的开头(即下标为 0 处)。注意, <code>queries[i]</code>&nbsp;的查询结果是 <code>queries[i]</code> <code>P</code> 中移动前的位置。</li>
</ul>

<p>请你以数组形式返回待查数组&nbsp; <code>queries</code> 的查询结果。</p>
<p>返回一个数组,包含从给定 &nbsp;<code>queries</code>&nbsp;中查询到的结果。</p>

<p>&nbsp;</p>

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

<pre><strong>输入:</strong>queries = [3,1,2,1], m = 5
<pre>
<strong>输入:</strong>queries = [3,1,2,1], m = 5
<strong>输出:</strong>[2,1,2,1]
<strong>解释:</strong>待查数组 queries 处理如下
对于 i=0: queries[i]=3, P=[1,2,3,4,5], 3 在 P 中的位置是 <strong>2</strong>,接着我们把 3 移动到 P 的起始位置,得到 P=[3,1,2,4,5] 。
对于 i=1: queries[i]=1, P=[3,1,2,4,5], 1 在 P 中的位置是 <strong>1</strong>,接着我们把 1 移动到 P 的起始位置,得到 P=[1,3,2,4,5] 。
对于 i=2: queries[i]=2, P=[1,3,2,4,5], 2 在 P 中的位置是 <strong>2</strong>,接着我们把 2 移动到 P 的起始位置,得到 P=[2,1,3,4,5] 。
对于 i=3: queries[i]=1, P=[2,1,3,4,5], 1 在 P 中的位置是 <strong>1</strong>,接着我们把 1 移动到 P 的起始位置,得到 P=[1,2,3,4,5] 。
因此,返回的结果数组为 [2,1,2,1] 。
<strong>解释:处理</strong> queries 的过程如下
对于 i=0: queries[i]=3, P=[1,2,3,4,5], 3 在 P 中的位置是 <strong>2</strong>,然后我们把 3 移动到 P 的开头,得到 P=[3,1,2,4,5] 。
对于 i=1: queries[i]=1, P=[3,1,2,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,3,2,4,5] 。
对于 i=2: queries[i]=2, P=[1,3,2,4,5], 2 在 P 中的位置是 <strong>2</strong>,然后我们把 2 移动到 P 的开头,得到 P=[2,1,3,4,5] 。
对于 i=3: queries[i]=1, P=[2,1,3,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,2,3,4,5] 。
因此,包含结果的数组为 [2,1,2,1] 。
</pre>

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

<pre><strong>输入:</strong>queries = [4,1,2,2], m = 4
<pre>
<strong>输入:</strong>queries = [4,1,2,2], m = 4
<strong>输出:</strong>[3,1,2,0]
</pre>

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

<pre><strong>输入:</strong>queries = [7,5,5,8,3], m = 8
<pre>
<strong>输入:</strong>queries = [7,5,5,8,3], m = 8
<strong>输出:</strong>[6,5,0,7,5]
</pre>

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

<ul>
<li>In the beginning, you have the permutation <code>P=[1,2,3,...,m]</code>.</li>
<li>For the current <code>i</code>, find the position of <code>queries[i]</code> in the permutation <code>P</code> (<strong>indexing from 0</strong>) and then move this at the beginning of the permutation <code>P.</code>&nbsp;Notice that the position of <code>queries[i]</code> in <code>P</code> is the result for <code>queries[i]</code>.</li>
<li>For the current <code>i</code>, find the position of <code>queries[i]</code> in the permutation <code>P</code> (<strong>indexing from 0</strong>) and then move this at the beginning of the permutation <code>P</code>. Notice that the position of <code>queries[i]</code> in <code>P</code> is the result for <code>queries[i]</code>.</li>
</ul>

<p>Return an array containing the result for the given <code>queries</code>.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,44 @@

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

<p>给你三个整数 <code>n</code>、<code>m</code> 和 <code>k</code> 。下图描述的算法用于找出正整数数组中最大的元素。</p>
<p>给定三个整数 <code>n</code>、<code>m</code> 和 <code>k</code> 。考虑使用下图描述的算法找出正整数数组中最大的元素。</p>

<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1420.Build%20Array%20Where%20You%20Can%20Find%20The%20Maximum%20Exactly%20K%20Comparisons/images/e.png" style="height: 372px; width: 424px;"></p>
<p><img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1400-1499/1420.Build%20Array%20Where%20You%20Can%20Find%20The%20Maximum%20Exactly%20K%20Comparisons/images/e.png" style="height: 372px; width: 424px;" /></p>

<p>请你生成一个具有下述属性的数组 <code>arr</code> :</p>
<p>请你构建一个具有以下属性的数组 <code>arr</code> :</p>

<ul>
<li><code>arr</code> 中有 <code>n</code> 个整数。</li>
<li><code>arr</code> 中包含确切的&nbsp;<code>n</code> 个整数。</li>
<li><code>1 &lt;= arr[i] &lt;= m</code> 其中 <code>(0 &lt;= i &lt; n)</code> 。</li>
<li>将上面提到的算法应用于 <code>arr</code> ,<code>search_cost</code> 的值等于 <code>k</code> 。</li>
<li>将上面提到的算法应用于 <code>arr</code>&nbsp;之后,<code>search_cost</code> 的值等于 <code>k</code> 。</li>
</ul>

<p>返回上述条件下生成数组 <code>arr</code> 的 <strong>方法数</strong> ,由于答案可能会很大,所以 <strong>必须</strong> 对 <code>10^9 + 7</code> 取余。</p>
<p>返回在满足上述条件的情况下构建数组 <code>arr</code> 的 <em>方法数量</em>&nbsp;,由于答案可能会很大,所以 <strong>必须</strong> 对 <code>10^9 + 7</code> 取余。</p>

<p>&nbsp;</p>

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

<pre><strong>输入:</strong>n = 2, m = 3, k = 1
<pre>
<strong>输入:</strong>n = 2, m = 3, k = 1
<strong>输出:</strong>6
<strong>解释:</strong>可能的数组分别为 [1, 1], [2, 1], [2, 2], [3, 1], [3, 2] [3, 3]
</pre>

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

<pre><strong>输入:</strong>n = 5, m = 2, k = 3
<pre>
<strong>输入:</strong>n = 5, m = 2, k = 3
<strong>输出:</strong>0
<strong>解释:</strong>没有数组可以满足上述条件
</pre>

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

<pre><strong>输入:</strong>n = 9, m = 1, k = 1
<pre>
<strong>输入:</strong>n = 9, m = 1, k = 1
<strong>输出:</strong>1
<strong>解释:</strong>可能的数组只有 [1, 1, 1, 1, 1, 1, 1, 1, 1]
</pre>

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

<pre><strong>输入:</strong>n = 50, m = 100, k = 25
<strong>输出:</strong>34549172
<strong>解释:</strong>不要忘了对 1000000007 取余
</pre>

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

<pre><strong>输入:</strong>n = 37, m = 17, k = 7
<strong>输出:</strong>418930126
<strong>解释:</strong>唯一可能的数组是 [1, 1, 1, 1, 1, 1, 1, 1, 1]
</pre>

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<pre>
<strong>Input:</strong> n = 5, m = 2, k = 3
<strong>Output:</strong> 0
<strong>Explanation:</strong> There are no possible arrays that satisify the mentioned conditions.
<strong>Explanation:</strong> There are no possible arrays that satisfy the mentioned conditions.
</pre>

<p><strong class="example">Example 3:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<p><strong class="example">Example 1:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2251.Number%20of%20Flowers%20in%20Full%20Bloom/images/ex1new.jpg" style="width: 550px; height: 216px;" />
<pre>
<strong>Input:</strong> flowers = [[1,6],[3,7],[9,12],[4,13]], poeple = [2,3,7,11]
<strong>Input:</strong> flowers = [[1,6],[3,7],[9,12],[4,13]], people = [2,3,7,11]
<strong>Output:</strong> [1,2,2,2]
<strong>Explanation: </strong>The figure above shows the times when the flowers are in full bloom and when the people arrive.
For each person, we return the number of flowers in full bloom during their arrival.
Expand All @@ -21,7 +21,7 @@ For each person, we return the number of flowers in full bloom during their arri
<p><strong class="example">Example 2:</strong></p>
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/2200-2299/2251.Number%20of%20Flowers%20in%20Full%20Bloom/images/ex2new.jpg" style="width: 450px; height: 195px;" />
<pre>
<strong>Input:</strong> flowers = [[1,10],[3,3]], poeple = [3,3,2]
<strong>Input:</strong> flowers = [[1,10],[3,3]], people = [3,3,2]
<strong>Output:</strong> [2,2,1]
<strong>Explanation:</strong> The figure above shows the times when the flowers are in full bloom and when the people arrive.
For each person, we return the number of flowers in full bloom during their arrival.
Expand Down
4 changes: 2 additions & 2 deletions solution/2600-2699/2668.Find Latest Salaries/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
| salary | varchar |
| department_id | varchar |
+---------------+---------+
在 SQL 中,(emp_id, salary) 是此表的主键。
(emp_id, salary) 是该表的主键(具有唯一值的列的组合)。
每行包含员工的详细信息和他们每年的薪水,但有些记录是旧的,包含过时的薪资信息。
</pre>

Expand All @@ -41,7 +41,7 @@
| 1 | Todd | Wilson | 110000 | D1006 |
| 1 | Todd | Wilson | 106119 | D1006 |
| 2 | Justin | Simon | 128922 | D1005 |
| 2 | Justin | Simon | 128922 | D1005 |
| 2 | Justin | Simon | 130000 | D1005 |
| 3 | Kelly | Rosario | 42689 | D1002 |
| 4 | Patricia | Powell | 162825 | D1004 |
| 4 | Patricia | Powell | 170000 | D1004 |
Expand Down
2 changes: 1 addition & 1 deletion solution/2600-2699/2668.Find Latest Salaries/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Each row contains employees details and their yearly salaries, however, some of
| 1 | Todd | Wilson | 110000 | D1006 |
| 1 | Todd | Wilson | 106119 | D1006 |
| 2 | Justin | Simon | 128922 | D1005 |
| 2 | Justin | Simon | 128922 | D1005 |
| 2 | Justin | Simon | 130000 | D1005 |
| 3 | Kelly | Rosario | 42689 | D1002 |
| 4 | Patricia | Powell | 162825 | D1004 |
| 4 | Patricia | Powell | 170000 | D1004 |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# [2893. Calculate Orders Within Each Interval](https://leetcode.cn/problems/calculate-orders-within-each-interval)
# [2893. 计算每个区间内的订单](https://leetcode.cn/problems/calculate-orders-within-each-interval)

[English Version](/solution/2800-2899/2893.Calculate%20Orders%20Within%20Each%20Interval/README_EN.md)

## 题目描述

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

<p>Table: <code><font face="monospace">Orders</font></code></p>
<p>表:&nbsp;<code><font face="monospace">Orders</font></code></p>

<pre>
+-------------+------+
Expand All @@ -15,25 +15,25 @@
| minute | int |
| order_count | int |
+-------------+------+
minute is the primary key for this table.
Each row of this table contains the minute and number of orders received during that specific minute. The total number of rows will be a multiple of 6.
</pre>
minute 是该表的主键。
该表的每一行包含分钟数以及在特定分钟数内收到的订单数量。总行数将是 6 的倍数。</pre>

<p>Write a query to calculate <strong>total</strong> <strong>orders</strong><b> </b>within each <strong>interval</strong>. Each interval is defined as a combination of <code>6</code> minutes.</p>
<p>编写一个查询,计算每个&nbsp;<strong>区间</strong><b>&nbsp;</b>内的&nbsp;<b>总订单数量。</b>&nbsp;每个区间被定义为&nbsp;<code>6</code>&nbsp;分钟的组合。</p>

<ul>
<li>Minutes <code>1</code> to <code>6</code> fall within interval <code>1</code>, while minutes <code>7</code> to <code>12</code> belong to interval <code>2</code>, and so forth.</li>
<li>&nbsp;<code>1</code>&nbsp;到&nbsp;<code>6</code>&nbsp;分钟属于第&nbsp;<code>1</code>&nbsp;个区间,而&nbsp;<code>7</code>&nbsp;到&nbsp;<code>12</code>&nbsp;分钟属于第&nbsp;<code>2</code>&nbsp;个区间,以此类推。</li>
</ul>

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

<p>The result format is in the following example.</p>
<p>结果表的格式如下示例所示。</p>

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

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

<pre>
<strong>Input:</strong>
<b>输入:</b>
Orders table:
+--------+-------------+
| minute | order_count |
Expand All @@ -51,17 +51,17 @@ Orders table:
| 11 | 4 |
| 12 | 6 |
+--------+-------------+
<strong>Output:</strong>
<b>输出:</b>
+-------------+--------------+
| interval_no | total_orders |
+-------------+--------------+
| 1 | 17 |
| 2 | 18 |
+-------------+--------------+
<strong>Explanation:</strong>
- Interval number 1 comprises minutes from 1 to 6. The total orders in these six minutes are (0 + 2 + 4 + 6 + 1 + 4) = 17.
- Interval number 2 comprises minutes from 7 to 12. The total orders in these six minutes are (1 + 2 + 4 + 1 + 4 + 6) = 18.
Returning table orderd by interval_no in ascending order.</pre>
<b>解释:</b>
- 区间号 1 包括从 1 到 6 分钟的时间。这 6 分钟内的总订单数量为 (0 + 2 + 4 + 6 + 1 + 4) = 17
- 区间号 2 包括从 7 到 12 分钟的时间。这 6 分钟内的总订单数量为 (1 + 2 + 4 + 1 + 4 + 6) = 18
按升序顺序返回结果表,按 interval_no 排序。</pre>

## 解法

Expand Down
2 changes: 1 addition & 1 deletion solution/DATABASE_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@
| 2837 | [总旅行距离](/solution/2800-2899/2837.Total%20Traveled%20Distance/README.md) | `数据库` | 简单 | 🔒 |
| 2853 | [最高薪水差异](/solution/2800-2899/2853.Highest%20Salaries%20Difference/README.md) | `数据库` | 简单 | 🔒 |
| 2854 | [滚动平均步数](/solution/2800-2899/2854.Rolling%20Average%20Steps/README.md) | `数据库` | 中等 | 🔒 |
| 2893 | [Calculate Orders Within Each Interval](/solution/2800-2899/2893.Calculate%20Orders%20Within%20Each%20Interval/README.md) | | 中等 | 🔒 |
| 2893 | [计算每个区间内的订单](/solution/2800-2899/2893.Calculate%20Orders%20Within%20Each%20Interval/README.md) | `数据库` | 中等 | 🔒 |

## 版权

Expand Down
Loading