Skip to content

feat: update lc problems #3446

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 2 commits into from
Aug 24, 2024
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
35 changes: 23 additions & 12 deletions solution/0000-0099/0020.Valid Parentheses/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,35 @@ tags:
<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;()&quot;
<strong>Output:</strong> true
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;()&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

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

<pre>
<strong>Input:</strong> s = &quot;()[]{}&quot;
<strong>Output:</strong> true
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;()[]{}&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

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

<pre>
<strong>Input:</strong> s = &quot;(]&quot;
<strong>Output:</strong> false
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;(]&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">false</span></p>
</div>

<p><strong class="example">Example 4:</strong></p>

<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">s = &quot;([])&quot;</span></p>

<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>
Expand Down
2 changes: 1 addition & 1 deletion solution/0100-0199/0134.Gas Station/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tags:

<p>You have a car with an unlimited gas tank and it costs <code>cost[i]</code> of gas to travel from the <code>i<sup>th</sup></code> station to its next <code>(i + 1)<sup>th</sup></code> station. You begin the journey with an empty tank at one of the gas stations.</p>

<p>Given two integer arrays <code>gas</code> and <code>cost</code>, return <em>the starting gas station&#39;s index if you can travel around the circuit once in the clockwise direction, otherwise return</em> <code>-1</code>. If there exists a solution, it is <strong>guaranteed</strong> to be <strong>unique</strong></p>
<p>Given two integer arrays <code>gas</code> and <code>cost</code>, return <em>the starting gas station&#39;s index if you can travel around the circuit once in the clockwise direction, otherwise return</em> <code>-1</code>. If there exists a solution, it is <strong>guaranteed</strong> to be <strong>unique</strong>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions solution/0100-0199/0152.Maximum Product Subarray/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tags:

<!-- description:start -->

<p>给你一个整数数组 <code>nums</code>&nbsp;,请你找出数组中乘积最大的非空连续<span data-keyword="subarray-nonempty">子数组</span>(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。</p>
<p>给你一个整数数组 <code>nums</code>&nbsp;,请你找出数组中乘积最大的非空连续 <span data-keyword="subarray-nonempty">子数组</span>(该子数组中至少包含一个数字),并返回该子数组所对应的乘积。</p>

<p>测试用例的答案是一个&nbsp;<strong>32-位</strong> 整数。</p>

Expand Down Expand Up @@ -45,7 +45,7 @@ tags:
<ul>
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>-10 &lt;= nums[i] &lt;= 10</code></li>
<li><code>nums</code> 的任何前缀或后缀的乘积都 <strong>保证</strong>&nbsp;是一个 <strong>32-位</strong> 整数</li>
<li><code>nums</code> 的任何子数组的乘积都 <strong>保证</strong>&nbsp;是一个 <strong>32-位</strong> 整数</li>
</ul>

<!-- description:end -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ tags:
<ul>
<li><code>1 &lt;= nums.length &lt;= 2 * 10<sup>4</sup></code></li>
<li><code>-10 &lt;= nums[i] &lt;= 10</code></li>
<li>The product of any prefix or suffix of <code>nums</code> is <strong>guaranteed</strong> to fit in a <strong>32-bit</strong> integer.</li>
<li>The product of any subarray of <code>nums</code> is <strong>guaranteed</strong> to fit in a <strong>32-bit</strong> integer.</li>
</ul>

<!-- description:end -->
Expand Down
37 changes: 18 additions & 19 deletions solution/0400-0499/0405.Convert a Number to Hexadecimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,35 +19,34 @@ tags:

<p>给定一个整数,编写一个算法将这个数转换为十六进制数。对于负整数,我们通常使用&nbsp;<a href="https://baike.baidu.com/item/%E8%A1%A5%E7%A0%81/6854613?fr=aladdin">补码运算</a>&nbsp;方法。</p>

<p><strong>注意:</strong></p>
<p>答案字符串中的所有字母都应该是小写字符,并且除了 0 本身之外,答案中不应该有任何前置零。</p>

<ol>
<li>十六进制中所有字母(<code>a-f</code>)都必须是小写。</li>
<li>十六进制字符串中不能包含多余的前导零。如果要转化的数为0,那么以单个字符<code>&#39;0&#39;</code>来表示;对于其他情况,十六进制字符串中的第一个字符将不会是0字符。&nbsp;</li>
<li>给定的数确保在32位有符号整数范围内。</li>
<li><strong>不能使用任何由库提供的将数字直接转换或格式化为十六进制的方法。</strong></li>
</ol>
<p><strong>注意: </strong>不允许使用任何由库提供的将数字直接转换或格式化为十六进制的方法来解决这个问题。</p>

<p><strong>示例 1:</strong></p>
<p>&nbsp;</p>

<pre>
输入:
26
<p><strong class="example">示例 1:</strong></p>

输出:
&quot;1a&quot;
<pre>
<b>输入:</b>num = 26
<b>输出:</b>"1a"
</pre>

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

<pre>
输入:
-1

输出:
&quot;ffffffff&quot;
<b>输入:</b>num = -1
<b>输出:</b>"ffffffff"
</pre>

<p>&nbsp;</p>

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

<ul>
<li><code>-2<sup>31</sup> &lt;= num &lt;= 2<sup>31</sup> - 1</code></li>
</ul>

<!-- description:end -->

## 解法
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tags:

<!-- description:start -->

<p>Given an integer <code>num</code>, return <em>a string representing its hexadecimal representation</em>. For negative integers, <a href="https://en.wikipedia.org/wiki/Two%27s_complement" target="_blank">two&rsquo;s complement</a> method is used.</p>
<p>Given a 32-bit integer <code>num</code>, return <em>a string representing its hexadecimal representation</em>. For negative integers, <a href="https://en.wikipedia.org/wiki/Two%27s_complement" target="_blank">two&rsquo;s complement</a> method is used.</p>

<p>All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself.</p>

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

<p>给你一个长度为 <code>n</code> 的整数数组 <code>nums</code> ,其中 <code>nums</code> 的所有整数都在范围 <code>[1, n]</code> 内,且每个整数出现 <strong>一次</strong> 或 <strong>两次</strong> 。请你找出所有出现 <strong>两次</strong> 的整数,并以数组形式返回。</p>

<p>你必须设计并实现一个时间复杂度为 <code>O(n)</code> 且仅使用常量额外空间的算法解决此问题。</p>
<p>你必须设计并实现一个时间复杂度为 <code>O(n)</code> 且仅使用常量额外空间(不包括存储输出所需的空间)的算法解决此问题。</p>

<p>&nbsp;</p>

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

<p>Given an integer array <code>nums</code> of length <code>n</code> where all the integers of <code>nums</code> are in the range <code>[1, n]</code> and each integer appears <strong>once</strong> or <strong>twice</strong>, return <em>an array of all the integers that appears <strong>twice</strong></em>.</p>

<p>You must write an algorithm that runs in&nbsp;<code>O(n)</code>&nbsp;time and uses only constant extra space.</p>
<p>You must write an algorithm that runs in <code>O(n)</code> time and uses only <em>constant</em> auxiliary space, excluding the space needed to store the output</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 @@ -27,7 +27,7 @@ tags:

<p>&nbsp;</p>

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

<pre>
<strong>输入: </strong>s = "tree"
Expand All @@ -36,7 +36,7 @@ tags:
因此'e'必须出现在'r'和't'之前。此外,"eetr"也是一个有效的答案。
</pre>

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

<pre>
<strong>输入: </strong>s = "cccaaa"
Expand All @@ -45,7 +45,7 @@ tags:
注意"cacaca"是不正确的,因为相同的字母必须放在一起。
</pre>

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

<pre>
<strong>输入: </strong>s = "Aabb"
Expand Down
30 changes: 17 additions & 13 deletions solution/0400-0499/0455.Assign Cookies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,45 @@ tags:

<p>假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。</p>

<p>对每个孩子 <code>i</code>,都有一个胃口值 <code>g[i]</code><sub>,</sub>这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 <code>j</code>,都有一个尺寸 <code>s[j]</code><sub> </sub>。如果 <code>s[j] >= g[i]</code>,我们可以将这个饼干 <code>j</code> 分配给孩子 <code>i</code> ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。</p>
 
<p>对每个孩子 <code>i</code>,都有一个胃口值&nbsp;<code>g[i]</code><sub>,</sub>这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 <code>j</code>,都有一个尺寸 <code>s[j]</code><sub>&nbsp;</sub>。如果 <code>s[j]&nbsp;&gt;= g[i]</code>,我们可以将这个饼干 <code>j</code> 分配给孩子 <code>i</code> ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。</p>
&nbsp;

<p><strong>示例 1:</strong></p>
<p><strong>示例&nbsp;1:</strong></p>

<pre>
<strong>输入:</strong> g = [1,2,3], s = [1,1]
<strong>输出:</strong> 1
<strong>解释:</strong>
你有三个孩子和两块小饼干,3个孩子的胃口值分别是:1,2,3。
虽然你有两块小饼干,由于他们的尺寸都是1,你只能让胃口值是1的孩子满足
所以你应该输出1
你有三个孩子和两块小饼干,3 个孩子的胃口值分别是:1,2,3。
虽然你有两块小饼干,由于他们的尺寸都是 1,你只能让胃口值是 1 的孩子满足
所以你应该输出 1
</pre>

<p><strong>示例 2:</strong></p>
<p><strong>示例&nbsp;2:</strong></p>

<pre>
<strong>输入:</strong> g = [1,2], s = [1,2,3]
<strong>输出:</strong> 2
<strong>解释:</strong>
你有两个孩子和三块小饼干,2个孩子的胃口值分别是1,2。
你有两个孩子和三块小饼干,2 个孩子的胃口值分别是 1,2。
你拥有的饼干数量和尺寸都足以让所有孩子满足。
所以你应该输出2.
所以你应该输出 2。
</pre>

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

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

<ul>
<li><code>1 <= g.length <= 3 * 10<sup>4</sup></code></li>
<li><code>0 <= s.length <= 3 * 10<sup>4</sup></code></li>
<li><code>1 <= g[i], s[j] <= 2<sup>31</sup> - 1</code></li>
<li><code>1 &lt;= g.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>0 &lt;= s.length &lt;= 3 * 10<sup>4</sup></code></li>
<li><code>1 &lt;= g[i], s[j] &lt;=&nbsp;2<sup>31</sup> - 1</code></li>
</ul>

<p>&nbsp;</p>

<p><strong>注意:</strong>本题与&nbsp;<a href="https://leetcode.cn/problems/maximum-matching-of-players-with-trainers/">2410. 运动员和训练师的最大匹配数</a>&nbsp;题相同。</p>

<!-- description:end -->

## 解法
Expand Down
3 changes: 3 additions & 0 deletions solution/0400-0499/0455.Assign Cookies/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ You need to output 2.
<li><code>1 &lt;= g[i], s[j] &lt;= 2<sup>31</sup> - 1</code></li>
</ul>

<p>&nbsp;</p>
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/maximum-matching-of-players-with-trainers/description/" target="_blank"> 2410: Maximum Matching of Players With Trainers.</a></p>

<!-- description:end -->

## Solutions
Expand Down
18 changes: 9 additions & 9 deletions solution/0500-0599/0596.Classes More Than 5 Students/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ tags:

<!-- problem:start -->

# [596. 超过5名学生的课](https://leetcode.cn/problems/classes-more-than-5-students)
# [596. 超过 5 名学生的课](https://leetcode.cn/problems/classes-more-than-5-students)

[English Version](/solution/0500-0599/0596.Classes%20More%20Than%205%20Students/README_EN.md)

Expand All @@ -25,21 +25,21 @@ tags:
| student | varchar |
| class | varchar |
+-------------+---------+
在 SQL 中,(student, class)是该表的主键列
(student, class)是该表的主键(不同值的列的组合)
该表的每一行表示学生的名字和他们注册的班级。
</pre>

<p>&nbsp;</p>

<p>查询&nbsp;<strong>至少有5个学生</strong> 的所有班级。</p>
<p>查询&nbsp;<strong>至少有 5 个学生</strong> 的所有班级。</p>

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

<p>查询结果格式如下所示。</p>
<p>结果格式如下所示。</p>

<p>&nbsp;</p>

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

<pre>
<strong>输入:</strong>
Expand All @@ -64,10 +64,10 @@ Courses table:
| Math &nbsp; &nbsp;|
+---------+
<strong>解释: </strong>
-数学课有6个学生,所以我们包括它。
-英语课有1名学生,所以我们不包括它。
-生物课有1名学生,所以我们不包括它。
-计算机课有1个学生,所以我们不包括它。</pre>
-数学课有 6 个学生,所以我们包括它。
-英语课有 1 名学生,所以我们不包括它。
-生物课有 1 名学生,所以我们不包括它。
-计算机课有 1 个学生,所以我们不包括它。</pre>

<!-- description:end -->

Expand Down
4 changes: 4 additions & 0 deletions solution/0600-0699/0608.Tree Node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ Tree table:
<b>解释:</b>如果树中只有一个节点,则只需要输出其根属性。
</pre>

<p>&nbsp;</p>

<p><strong>注意:</strong>本题与 <a href="https://leetcode.cn/problems/binary-tree-nodes/">3054. 二叉树节点</a> 一致。</p>

<!-- description:end -->

## 解法
Expand Down
3 changes: 3 additions & 0 deletions solution/0600-0699/0608.Tree Node/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ Tree table:
<strong>Explanation:</strong> If there is only one node on the tree, you only need to output its root attributes.
</pre>

<p>&nbsp;</p>
<p><strong>Note:</strong> This question is the same as <a href="https://leetcode.com/problems/binary-tree-nodes/description/" target="_blank"> 3054: Binary Tree Nodes.</a></p>

<!-- description:end -->

## Solutions
Expand Down
Loading
Loading