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 #1849

Merged
merged 2 commits into from
Oct 20, 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
16 changes: 8 additions & 8 deletions solution/0000-0099/0062.Unique Paths/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

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

<p>一个机器人位于一个 <code>m x n</code><em> </em>网格的左上角 (起始点在下图中标记为 “Start” )。</p>
<p>一个机器人位于一个 <code>m x n</code><em>&nbsp;</em>网格的左上角 (起始点在下图中标记为 “Start” )。</p>

<p>机器人每次只能向下或者向右移动一步。机器人试图达到网格的右下角(在下图中标记为 “Finish” )。</p>

<p>问总共有多少条不同的路径?</p>

<p> </p>
<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0062.Unique%20Paths/images/robot_maze.png" />
<img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0062.Unique%20Paths/images/1697422740-adxmsI-image.png" style="width: 400px; height: 183px;" />
<pre>
<strong>输入:</strong>m = 3, n = 7
<strong>输出:</strong>28</pre>
Expand All @@ -27,9 +27,9 @@
<strong>输出:</strong>3
<strong>解释:</strong>
从左上角开始,总共有 3 条路径可以到达右下角。
1. 向右 -> 向下 -> 向下
2. 向下 -> 向下 -> 向右
3. 向下 -> 向右 -> 向下
1. 向右 -&gt; 向下 -&gt; 向下
2. 向下 -&gt; 向下 -&gt; 向右
3. 向下 -&gt; 向右 -&gt; 向下
</pre>

<p><strong>示例 3:</strong></p>
Expand All @@ -45,12 +45,12 @@
<strong>输入:</strong>m = 3, n = 3
<strong>输出:</strong>6</pre>

<p> </p>
<p>&nbsp;</p>

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

<ul>
<li><code>1 <= m, n <= 100</code></li>
<li><code>1 &lt;= m, n &lt;= 100</code></li>
<li>题目数据保证答案小于等于 <code>2 * 10<sup>9</sup></code></li>
</ul>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion solution/0200-0299/0284.Peeking Iterator/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# [284. 顶端迭代器](https://leetcode.cn/problems/peeking-iterator)
# [284. 窥视迭代器](https://leetcode.cn/problems/peeking-iterator)

[English Version](/solution/0200-0299/0284.Peeking%20Iterator/README_EN.md)

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

<p>给你一个字符串 <code>s</code> 和一个整数 <code>k</code> 。你可以选择字符串中的任一字符,并将其更改为任何其他大写英文字符。该操作最多可执行 <code>k</code> 次。</p>

<p>在执行上述操作后,返回包含相同字母的最长子字符串的长度。</p>
<p>在执行上述操作后,返回 <em>包含相同字母的最长子字符串的长度。</em></p>

<p>&nbsp;</p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<strong>Output:</strong> 4
<strong>Explanation:</strong> Replace the one &#39;A&#39; in the middle with &#39;B&#39; and form &quot;AABBBBA&quot;.
The substring &quot;BBBB&quot; has the longest repeating letters, which is 4.
There may exists other ways to achive this answer too.</pre>
There may exists other ways to achieve this answer too.</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0400-0499/0472.Concatenated Words/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
<ul>
<li><code>1 &lt;= words.length &lt;= 10<sup>4</sup></code></li>
<li><code>1 &lt;= words[i].length &lt;= 30</code></li>
<li><code>words[i]</code>&nbsp;仅由小写英文字母组成。</li>
<li>&nbsp;<code>words</code>&nbsp;中的所有字符串都是 <strong>唯一</strong> 的。</li>
<li><code>words[i]</code>&nbsp;仅由小写英文字母组成。&nbsp;</li>
<li><code>words</code>&nbsp;中的所有字符串都是 <strong>唯一</strong> 的。</li>
<li><code>1 &lt;= sum(words[i].length) &lt;= 10<sup>5</sup></code></li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion solution/0400-0499/0472.Concatenated Words/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<p>Given an array of strings <code>words</code> (<strong>without duplicates</strong>), return <em>all the <strong>concatenated words</strong> in the given list of</em> <code>words</code>.</p>

<p>A <strong>concatenated word</strong> is defined as a string that is comprised entirely of at least two shorter words (not necesssarily distinct)&nbsp;in the given array.</p>
<p>A <strong>concatenated word</strong> is defined as a string that is comprised entirely of at least two shorter words (not necessarily distinct)&nbsp;in the given array.</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 @@ -25,22 +25,15 @@
<pre>
<strong>输入:</strong>nums = [1,2,3,4]
<strong>输出:</strong>-1
<strong>解释:</strong>4 没有超过 3 的两倍大,所以返回 -1 。</pre>

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

<pre>
<strong>输入:</strong>nums = [1]
<strong>输出:</strong>0
<strong>解释:</strong>因为不存在其他数字,所以认为现有数字 1 至少是其他数字的两倍。
<strong>解释:</strong>4 没有超过 3 的两倍大,所以返回 -1 。
</pre>

<p>&nbsp;</p>

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

<ul>
<li><code>1 &lt;= nums.length &lt;= 50</code></li>
<li><code>2 &lt;= nums.length &lt;= 50</code></li>
<li><code>0 &lt;= nums[i] &lt;= 100</code></li>
<li><code>nums</code> 中的最大元素是唯一的</li>
</ul>
Expand Down
26 changes: 10 additions & 16 deletions solution/0900-0999/0981.Time Based Key-Value Store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,12 @@

<ul>
<li><code>TimeMap()</code> 初始化数据结构对象</li>
<li><code>void set(String key, String value, int timestamp)</code> 存储键 <code>key</code>、值 <code>value</code>,以及给定的时间戳 <code>timestamp</code>。</li>
<li><code>String get(String key, int timestamp)</code>
<ul>
<li>返回先前调用 <code>set(key, value, timestamp_prev)</code> 所存储的值,其中 <code>timestamp_prev <= timestamp</code> 。</li>
<li>如果有多个这样的值,则返回对应最大的  <code>timestamp_prev</code> 的那个值。</li>
<li>如果没有值,则返回空字符串(<code>""</code>)。</li>
</ul>
</li>
<li><code>void set(String key, String value, int timestamp)</code> 存储给定时间戳&nbsp;<code>timestamp</code>&nbsp;时的键&nbsp;<code>key</code>&nbsp;和值&nbsp;<code>value</code>。</li>
<li><code>String get(String key, int timestamp)</code>&nbsp;返回一个值,该值在之前调用了 <code>set</code>,其中&nbsp;<code>timestamp_prev &lt;= timestamp</code>&nbsp;。如果有多个这样的值,它将返回与最大 &nbsp;<code>timestamp_prev</code>&nbsp;关联的值。如果没有值,则返回空字符串(<code>""</code>)。</li>
</ul>
 
&nbsp;

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

<pre>
<strong>输入:</strong>
Expand All @@ -34,24 +28,24 @@

<strong>解释:</strong>
TimeMap timeMap = new TimeMap();
timeMap.set("foo", "bar", 1); // 存储键 "foo" 和值 "bar" ,时间戳 timestamp = 1  
timeMap.set("foo", "bar", 1); // 存储键 "foo" 和值 "bar" ,时间戳 timestamp = 1 &nbsp;
timeMap.get("foo", 1); // 返回 "bar"
timeMap.get("foo", 3); // 返回 "bar", 因为在时间戳 3 和时间戳 2 处没有对应 "foo" 的值,所以唯一的值位于时间戳 1 处(即 "bar") 。
timeMap.set("foo", "bar2", 4); // 存储键 "foo" 和值 "bar2" ,时间戳 timestamp = 4 
timeMap.set("foo", "bar2", 4); // 存储键 "foo" 和值 "bar2" ,时间戳 timestamp = 4&nbsp;
timeMap.get("foo", 4); // 返回 "bar2"
timeMap.get("foo", 5); // 返回 "bar2"
</pre>

<p> </p>
<p>&nbsp;</p>

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

<ul>
<li><code>1 <= key.length, value.length <= 100</code></li>
<li><code>1 &lt;= key.length, value.length &lt;= 100</code></li>
<li><code>key</code> 和 <code>value</code> 由小写英文字母和数字组成</li>
<li><code>1 <= timestamp <= 10<sup>7</sup></code></li>
<li><code>1 &lt;= timestamp &lt;= 10<sup>7</sup></code></li>
<li><code>set</code> 操作中的时间戳 <code>timestamp</code> 都是严格递增的</li>
<li>最多调用 <code>set</code> 和 <code>get</code> 操作 <code>2 * 10<sup>5</sup></code> 次</li>
<li>最多调用&nbsp;<code>set</code> 和 <code>get</code> 操作 <code>2 * 10<sup>5</sup></code> 次</li>
</ul>

## 解法
Expand Down
18 changes: 9 additions & 9 deletions solution/1100-1199/1159.Market Analysis II/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
| join_date | date |
| favorite_brand | varchar |
+----------------+---------+
user_id 是该表的主键(具有唯一值的列)
user_id 是该表的主键(具有唯一值的列)
表中包含一位在线购物网站用户的个人信息,用户可以在该网站出售和购买商品。
</pre>

Expand All @@ -32,9 +32,9 @@ user_id 是该表的主键(具有唯一值的列)
| buyer_id | int |
| seller_id | int |
+---------------+---------+
order_id 是该表的主键(具有唯一值的列)
item_id 是 Items 表的外键(reference 列)
buyer_id 和 seller_id 是 Users 表的外键
order_id 是该表的主键(具有唯一值的列)
item_id 是 Items 表的外键(reference 列)
buyer_id 和 seller_id 是 Users 表的外键
</pre>

<p>表: <code>Items</code></p>
Expand All @@ -46,16 +46,16 @@ buyer_id 和 seller_id 是 Users 表的外键
| item_id | int |
| item_brand | varchar |
+---------------+---------+
item_id 是该表的主键(具有唯一值的列)
item_id 是该表的主键(具有唯一值的列)
</pre>

<p>&nbsp;</p>

<p>编写解决方案找出每一个用户按日期顺序卖出的第二件商品的品牌是否是他们最喜爱的品牌。如果一个用户卖出少于两件商品,查询的结果是 <code>no</code> 。题目保证没有一个用户在一天中卖出超过一件商品。</p>
<p>编写一个解决方案,查找每个用户的加入日期和作为买家在 <code>2019</code> 年下的订单数。</p>

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

<p>返回结果格式的例子如下所示:</p>
<p>返回结果格式如下例所示:</p>

<p>&nbsp;</p>

Expand Down Expand Up @@ -103,7 +103,7 @@ Items table:
+-----------+--------------------+
<strong>解释:</strong>
id 为 1 的用户的查询结果是 no,因为他什么也没有卖出
id为 2 和 3 的用户的查询结果是 yes,因为他们卖出的第二件商品的品牌是他们自己最喜爱的品牌
id为 2 和 3 的用户的查询结果是 yes,因为他们卖出的第二件商品的品牌是他们最喜爱的品牌
id为 4 的用户的查询结果是 no,因为他卖出的第二件商品的品牌不是他最喜爱的品牌
</pre>

Expand Down
37 changes: 20 additions & 17 deletions solution/1300-1399/1349.Maximum Students Taking Exam/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,46 @@

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

<p>给你一个&nbsp;<code>m&nbsp;* n</code>&nbsp;的矩阵 <code>seats</code>&nbsp;表示教室中的座位分布。如果座位是坏的(不可用),就用&nbsp;<code>&#39;#&#39;</code>&nbsp;表示;否则,用&nbsp;<code>&#39;.&#39;</code>&nbsp;表示。</p>
<p>给你一个&nbsp;<code>m&nbsp;* n</code>&nbsp;的矩阵 <code>seats</code>&nbsp;表示教室中的座位分布。如果座位是坏的(不可用),就用&nbsp;<code>'#'</code>&nbsp;表示;否则,用&nbsp;<code>'.'</code>&nbsp;表示。</p>

<p>学生可以看到左侧、右侧、左上、右上这四个方向上紧邻他的学生的答卷,但是看不到直接坐在他前面或者后面的学生的答卷。请你计算并返回该考场可以容纳的一起参加考试且无法作弊的最大学生人数。</p>
<p>学生可以看到左侧、右侧、左上、右上这四个方向上紧邻他的学生的答卷,但是看不到直接坐在他前面或者后面的学生的答卷。请你计算并返回该考场可以容纳的同时参加考试且无法作弊的&nbsp;<strong>最大&nbsp;</strong>学生人数。</p>

<p>学生必须坐在状况良好的座位上。</p>

<p>&nbsp;</p>

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

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1349.Maximum%20Students%20Taking%20Exam/images/image.png" style="height: 197px; width: 339px;"></p>
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/1300-1399/1349.Maximum%20Students%20Taking%20Exam/images/image.png" style="height: 197px; width: 339px;" /></p>

<pre><strong>输入:</strong>seats = [[&quot;#&quot;,&quot;.&quot;,&quot;#&quot;,&quot;#&quot;,&quot;.&quot;,&quot;#&quot;],
&nbsp; [&quot;.&quot;,&quot;#&quot;,&quot;#&quot;,&quot;#&quot;,&quot;#&quot;,&quot;.&quot;],
&nbsp; [&quot;#&quot;,&quot;.&quot;,&quot;#&quot;,&quot;#&quot;,&quot;.&quot;,&quot;#&quot;]]
<pre>
<strong>输入:</strong>seats = [["#",".","#","#",".","#"],
&nbsp; [".","#","#","#","#","."],
&nbsp; ["#",".","#","#",".","#"]]
<strong>输出:</strong>4
<strong>解释:</strong>教师可以让 4 个学生坐在可用的座位上,这样他们就无法在考试中作弊。
</pre>

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

<pre><strong>输入:</strong>seats = [[&quot;.&quot;,&quot;#&quot;],
&nbsp; [&quot;#&quot;,&quot;#&quot;],
&nbsp; [&quot;#&quot;,&quot;.&quot;],
&nbsp; [&quot;#&quot;,&quot;#&quot;],
&nbsp; [&quot;.&quot;,&quot;#&quot;]]
<pre>
<strong>输入:</strong>seats = [[".","#"],
&nbsp; ["#","#"],
&nbsp; ["#","."],
&nbsp; ["#","#"],
&nbsp; [".","#"]]
<strong>输出:</strong>3
<strong>解释:</strong>让所有学生坐在可用的座位上。
</pre>

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

<pre><strong>输入:</strong>seats = [[&quot;#&quot;,&quot;.&quot;,&quot;<strong>.</strong>&quot;,&quot;.&quot;,&quot;#&quot;],
&nbsp; [&quot;<strong>.</strong>&quot;,&quot;#&quot;,&quot;<strong>.</strong>&quot;,&quot;#&quot;,&quot;<strong>.</strong>&quot;],
&nbsp; [&quot;<strong>.</strong>&quot;,&quot;.&quot;,&quot;#&quot;,&quot;.&quot;,&quot;<strong>.</strong>&quot;],
&nbsp; [&quot;<strong>.</strong>&quot;,&quot;#&quot;,&quot;<strong>.</strong>&quot;,&quot;#&quot;,&quot;<strong>.</strong>&quot;],
&nbsp; [&quot;#&quot;,&quot;.&quot;,&quot;<strong>.</strong>&quot;,&quot;.&quot;,&quot;#&quot;]]
<pre>
<strong>输入:</strong>seats = [["#",".","<strong>.</strong>",".","#"],
&nbsp; ["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
&nbsp; ["<strong>.</strong>",".","#",".","<strong>.</strong>"],
&nbsp; ["<strong>.</strong>","#","<strong>.</strong>","#","<strong>.</strong>"],
&nbsp; ["#",".","<strong>.</strong>",".","#"]]
<strong>输出:</strong>10
<strong>解释:</strong>让学生坐在第 1、3 和 5 列的可用座位上。
</pre>
Expand All @@ -52,7 +55,7 @@
<p><strong>提示:</strong></p>

<ul>
<li><code>seats</code>&nbsp;只包含字符&nbsp;<code>&#39;.&#39;&nbsp;和</code><code>&#39;#&#39;</code></li>
<li><code>seats</code>&nbsp;只包含字符&nbsp;<code>'.'&nbsp;和</code><code>'#'</code></li>
<li><code>m ==&nbsp;seats.length</code></li>
<li><code>n ==&nbsp;seats[i].length</code></li>
<li><code>1 &lt;= m &lt;= 8</code></li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

<p>Given <code>n</code> orders,each order consists of a pickup and a delivery service.</p>
<p>Given <code>n</code> orders, each order consists of a pickup and a delivery service.</p>

<p>Count all valid pickup/delivery possible sequences such that delivery(i) is always after of&nbsp;pickup(i).&nbsp;</p>

Expand Down
10 changes: 5 additions & 5 deletions solution/1400-1499/1402.Reducing Dishes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

<p>一个厨师收集了他&nbsp;<code>n</code>&nbsp;道菜的满意程度&nbsp;<code>satisfaction</code>&nbsp;,这个厨师做出每道菜的时间都是 1 单位时间。</p>

<p>一道菜的 「喜爱时间」系数定义为烹饪这道菜以及之前每道菜所花费的时间乘以这道菜的满意程度,也就是&nbsp;<code>time[i]</code>*<code>satisfaction[i]</code>&nbsp;。</p>
<p>一道菜的 「&nbsp;<strong>like-time 系数&nbsp;</strong>」定义为烹饪这道菜结束的时间(包含之前每道菜所花费的时间)乘以这道菜的满意程度,也就是&nbsp;<code>time[i]</code>*<code>satisfaction[i]</code>&nbsp;。</p>

<p>请你返回做完所有菜 「喜爱时间」总和的最大值为多少。</p>
<p>返回厨师在准备了一定数量的菜肴后可以获得的最大 <strong>like-time 系数</strong> 总和。</p>

<p>你可以按&nbsp;<strong>任意</strong>&nbsp;顺序安排做菜的顺序,你也可以选择放弃做某些菜来获得更大的总和。</p>

Expand All @@ -21,22 +21,22 @@
<pre>
<strong>输入:</strong>satisfaction = [-1,-8,0,5,-9]
<strong>输出:</strong>14
<strong>解释:</strong>去掉第二道和最后一道菜,最大的喜爱时间系数和为 (-1*1 + 0*2 + 5*3 = 14) 。每道菜都需要花费 1 单位时间完成。</pre>
<strong>解释:</strong>去掉第二道和最后一道菜,最大的 like-time 系数和为 (-1*1 + 0*2 + 5*3 = 14) 。每道菜都需要花费 1 单位时间完成。</pre>

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

<pre>
<strong>输入:</strong>satisfaction = [4,3,2]
<strong>输出:</strong>20
<strong>解释:</strong>按照原来顺序相反的时间做菜 (2*1 + 3*2 + 4*3 = 20)
<strong>解释:可以</strong>按照任意顺序做菜 (2*1 + 3*2 + 4*3 = 20)
</pre>

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

<pre>
<strong>输入:</strong>satisfaction = [-1,-4,-5]
<strong>输出:</strong>0
<strong>解释:</strong>大家都不喜欢这些菜,所以不做任何菜可以获得最大的喜爱时间系数
<strong>解释:</strong>大家都不喜欢这些菜,所以不做任何菜就可以获得最大的 like-time 系数
</pre>

<p>&nbsp;</p>
Expand Down
2 changes: 1 addition & 1 deletion solution/1400-1499/1402.Reducing Dishes/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<p><strong>Like-time coefficient</strong> of a dish is defined as the time taken to cook that dish including previous dishes multiplied by its satisfaction level i.e. <code>time[i] * satisfaction[i]</code>.</p>

<p>Return <em>the maximum sum of <strong>like-time coefficient</strong> that the chef can obtain after dishes preparation</em>.</p>
<p>Return the maximum sum of <strong>like-time coefficient </strong>that the chef can obtain after preparing some amount of dishes.</p>

<p>Dishes can be prepared in <strong>any </strong>order and the chef can discard some dishes to get this maximum value.</p>

Expand Down
Loading