Skip to content

feat: update lc problems #4599

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
Jul 26, 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
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tags:

<p>给出数字到字母的映射如下(与电话按键相同)。注意 1 不对应任何字母。</p>

<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0017.Letter%20Combinations%20of%20a%20Phone%20Number/images/200px-telephone-keypad2svg.png" style="width: 200px;" /></p>
<p><img src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0000-0099/0017.Letter%20Combinations%20of%20a%20Phone%20Number/images/1752723054-mfIHZs-image.png" style="width: 200px;" /></p>

<p>&nbsp;</p>

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions solution/0000-0099/0020.Valid Parentheses/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ tags:
<p><span class="example-io"><b>输出:</b>true</span></p>
</div>

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

<div class="example-block">
<p><span class="example-io"><b>输入:</b>s = "([)]"</span></p>

<p><span class="example-io"><b>输出:</b>false</span></p>
</div>

<p>&nbsp;</p>

<p><strong>提示:</strong></p>
Expand Down
8 changes: 8 additions & 0 deletions solution/0000-0099/0020.Valid Parentheses/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ tags:
<p><strong>Output:</strong> <span class="example-io">true</span></p>
</div>

<p><strong class="example">Example 5:</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">false</span></p>
</div>

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

Expand Down
71 changes: 55 additions & 16 deletions solution/0100-0199/0190.Reverse Bits/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,67 @@ tags:

<p>&nbsp;</p>

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

<pre>
<strong>输入:</strong>n = 00000010100101000001111010011100
<strong>输出:</strong>964176192 (00111001011110000010100101000000)
<strong>解释:</strong>输入的二进制串 <strong>00000010100101000001111010011100 </strong>表示无符号整数<strong> 43261596</strong><strong>,
</strong> 因此返回 964176192,其二进制表示形式为 <strong>00111001011110000010100101000000</strong>。</pre>

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

<pre>
<strong>输入:</strong>n = 11111111111111111111111111111101
<strong>输出:</strong>3221225471 (10111111111111111111111111111111)
<strong>解释:</strong>输入的二进制串 <strong>11111111111111111111111111111101</strong> 表示无符号整数 4294967293,
&nbsp; 因此返回 3221225471 其二进制表示形式为 <strong>10111111111111111111111111111111 。</strong></pre>
<p><strong class="example">示例 1:</strong></p>

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

<p><span class="example-io"><b>输出:</b>964176192</span></p>

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

<table>
<tbody>
<tr>
<th>整数</th>
<th>二进制</th>
</tr>
<tr>
<td>43261596</td>
<td>00000010100101000001111010011100</td>
</tr>
<tr>
<td>964176192</td>
<td>00111001011110000010100101000000</td>
</tr>
</tbody>
</table>
</div>

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

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

<p><span class="example-io"><b>输出:</b>1073741822</span></p>

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

<table>
<tbody>
<tr>
<th>整数</th>
<th>二进制</th>
</tr>
<tr>
<td>2147483644</td>
<td>01111111111111111111111111111100</td>
</tr>
<tr>
<td>1073741822</td>
<td>00111111111111111111111111111110</td>
</tr>
</tbody>
</table>
</div>

<p>&nbsp;</p>

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

<ul>
<li>输入是一个长度为 <code>32</code> 的二进制字符串</li>
<li><code>0 &lt;= n &lt;= 2<sup>31</sup>&nbsp;- 2</code></li>
<li><code>n</code>&nbsp;为偶数</li>
</ul>

<p>&nbsp;</p>
Expand Down
63 changes: 51 additions & 12 deletions solution/0100-0199/0190.Reverse Bits/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,70 @@ tags:

<ul>
<li>Note that in some languages, such as Java, there is no unsigned integer type. In this case, both input and output will be given as a signed integer type. They should not affect your implementation, as the integer&#39;s internal binary representation is the same, whether it is signed or unsigned.</li>
<li>In Java, the compiler represents the signed integers using <a href="https://en.wikipedia.org/wiki/Two%27s_complement" target="_blank">2&#39;s complement notation</a>. Therefore, in <strong class="example">Example 2</strong> above, the input represents the signed integer <code>-3</code> and the output represents the signed integer <code>-1073741825</code>.</li>
<li>In Java, the compiler represents the signed integers using <a href="https://en.wikipedia.org/wiki/Two%27s_complement" target="_blank">2&#39;s complement notation</a>. Therefore, in <strong class="example">Example 2</strong>&nbsp;below, the input represents the signed integer <code>-3</code> and the output represents the signed integer <code>-1073741825</code>.</li>
</ul>

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

<pre>
<strong>Input:</strong> n = 00000010100101000001111010011100
<strong>Output:</strong> 964176192 (00111001011110000010100101000000)
<strong>Explanation: </strong>The input binary string <strong>00000010100101000001111010011100</strong> represents the unsigned integer 43261596, so return 964176192 which its binary representation is <strong>00111001011110000010100101000000</strong>.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 43261596</span></p>

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

<p><strong>Explanation:</strong></p>

<table>
<tbody>
<tr>
<th>Integer</th>
<th>Binary</th>
</tr>
<tr>
<td>43261596</td>
<td>00000010100101000001111010011100</td>
</tr>
<tr>
<td>964176192</td>
<td>00111001011110000010100101000000</td>
</tr>
</tbody>
</table>
</div>

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

<pre>
<strong>Input:</strong> n = 11111111111111111111111111111101
<strong>Output:</strong> 3221225471 (10111111111111111111111111111111)
<strong>Explanation: </strong>The input binary string <strong>11111111111111111111111111111101</strong> represents the unsigned integer 4294967293, so return 3221225471 which its binary representation is <strong>10111111111111111111111111111111</strong>.
</pre>
<div class="example-block">
<p><strong>Input:</strong> <span class="example-io">n = 2147483644</span></p>

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

<p><strong>Explanation:</strong></p>

<table>
<tbody>
<tr>
<th>Integer</th>
<th>Binary</th>
</tr>
<tr>
<td>2147483644</td>
<td>01111111111111111111111111111100</td>
</tr>
<tr>
<td>1073741822</td>
<td>00111111111111111111111111111110</td>
</tr>
</tbody>
</table>
</div>

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

<ul>
<li>The input must be a <strong>binary string</strong> of length <code>32</code></li>
<li><code>0 &lt;= n &lt;= 2<sup>31</sup> - 2</code></li>
<li><code>n</code> is even.</li>
</ul>

<p>&nbsp;</p>
Expand Down
4 changes: 3 additions & 1 deletion solution/0200-0299/0282.Expression Add Operators/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ tags:

<!-- description:start -->

<p>给定一个仅包含数字&nbsp;<code>0-9</code>&nbsp;的字符串 <code>num</code> 和一个目标值整数 <code>target</code> ,在 <code>num</code> 的数字之间添加 <strong>二元 </strong>运算符(不是一元)<code>+</code>、<code>-</code>&nbsp;或&nbsp;<code>*</code>&nbsp;,返回 <strong>所有</strong> 能够得到 <code>target </code>的表达式。</p>
<p>给定一个仅包含数字&nbsp;<code>0-9</code>&nbsp;的字符串 <code>num</code> 和一个目标值整数 <code>target</code> ,在 <code>num</code> 的数字之间添加 <strong>二元 </strong>运算符(不是一元)<code>+</code>、<code>-</code>&nbsp;或&nbsp;<code>*</code>&nbsp;,返回 <strong>所有</strong> 能够得到 <code>target</code>&nbsp;的表达式。</p>

<p>注意,返回表达式中的操作数 <strong>不应该</strong> 包含前导零。</p>

<p><strong>注意</strong>,一个数字可以包含多个数位。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>
Expand Down
17 changes: 14 additions & 3 deletions solution/0300-0399/0348.Design Tic-Tac-Toe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tags:

<!-- description:start -->

<p>请在 n &times;&nbsp;n 的棋盘上,实现一个判定井字棋(Tic-Tac-Toe)胜负的神器,判断每一次玩家落子后,是否有胜出的玩家。</p>
<p>请在 n ×&nbsp;n 的棋盘上,实现一个判定井字棋(Tic-Tac-Toe)胜负的神器,判断每一次玩家落子后,是否有胜出的玩家。</p>

<p>在这个井字棋游戏中,会有 2 名玩家,他们将轮流在棋盘上放置自己的棋子。</p>

Expand All @@ -34,7 +34,8 @@ tags:

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

<pre>给定棋盘边长 <em>n</em> = 3, 玩家 1 的棋子符号是 &quot;X&quot;,玩家 2 的棋子符号是 &quot;O&quot;。
<pre>
给定棋盘边长 <em>n</em> = 3, 玩家 1 的棋子符号是 "X",玩家 2 的棋子符号是 "O"。

TicTacToe toe = new TicTacToe(3);

Expand Down Expand Up @@ -76,7 +77,17 @@ toe.move(2, 1, 1); -&gt; 函数返回 1 (此时,玩家 1 赢得了该场比赛

<p>&nbsp;</p>

<p><strong>进阶:</strong><br>
<p><strong>提示:</strong></p>

<ul>
<li><code>2 &lt;= n &lt;= 100</code></li>
<li>玩家是&nbsp;<code>1</code> 或&nbsp;<code>2</code>。</li>
<li><code>0 &lt;= row, col &lt; n</code></li>
<li>每次调用 <code>move</code>&nbsp;时&nbsp;<code>(row, col)</code>&nbsp;都是不同的。</li>
<li>最多调用&nbsp;<code>move</code>&nbsp;&nbsp;<code>n<sup>2</sup></code>&nbsp;次。</li>
</ul>

<p><strong>进阶:</strong><br />
您有没有可能将每一步的&nbsp;<code>move()</code>&nbsp;操作优化到比&nbsp;O(<em>n</em><sup>2</sup>) 更快吗?</p>

<!-- description:end -->
Expand Down
3 changes: 3 additions & 0 deletions solution/0300-0399/0391.Perfect Rectangle/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0300-0399/0391.Perfect%20Rectangle/README.md
tags:
- 几何
- 数组
- 哈希表
- 数学
- 扫描线
---

Expand Down
3 changes: 3 additions & 0 deletions solution/0300-0399/0391.Perfect Rectangle/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0300-0399/0391.Perfect%20Rectangle/README_EN.md
tags:
- Geometry
- Array
- Hash Table
- Math
- Line Sweep
---

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

<ul>
<li>The root node&#39;s left child is in the left boundary. If the root does not have a left child, then the left boundary is <strong>empty</strong>.</li>
<li>If a node in the left boundary and has a left child, then the left child is in the left boundary.</li>
<li>If a node is in the left boundary and has a left child, then the left child is in the left boundary.</li>
<li>If a node is in the left boundary, has <strong>no</strong> left child, but has a right child, then the right child is in the left boundary.</li>
<li>The leftmost leaf is <strong>not</strong> in the left boundary.</li>
</ul>
Expand Down
7 changes: 6 additions & 1 deletion solution/0500-0599/0584.Find Customer Referee/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ tags:
在 SQL 中,id 是该表的主键列。
该表的每一行表示一个客户的 id、姓名以及推荐他们的客户的 id。</pre>

<p>找出那些 <strong>没有被</strong> <code>id = 2</code> 的客户 <strong>推荐</strong> 的客户的姓名。</p>
<p>找出以下客户的姓名:</p>

<ol>
<li><strong>被任何</strong>&nbsp;<code>id != 2</code>&nbsp;的用户推荐。</li>
<li><strong>没有被</strong>&nbsp;任何用户推荐。</li>
</ol>

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

Expand Down
7 changes: 6 additions & 1 deletion solution/0500-0599/0584.Find Customer Referee/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ Each row of this table indicates the id of a customer, their name, and the id of

<p>&nbsp;</p>

<p>Find the names of the customer that are <strong>not referred by</strong> the customer with <code>id = 2</code>.</p>
<p>Find the names of the customer that are either:</p>

<ol>
<li><strong>referred by</strong>&nbsp;any&nbsp;customer with&nbsp;<code>id != 2</code>.</li>
<li><strong>not referred by</strong> any customer.</li>
</ol>

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

Expand Down
6 changes: 4 additions & 2 deletions solution/0700-0799/0778.Swim in Rising Water/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ tags:

<p>You are given an <code>n x n</code> integer matrix <code>grid</code> where each value <code>grid[i][j]</code> represents the elevation at that point <code>(i, j)</code>.</p>

<p>The rain starts to fall. At time <code>t</code>, the depth of the water everywhere is <code>t</code>. You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most <code>t</code>. You can swim infinite distances in zero time. Of course, you must stay within the boundaries of the grid during your swim.</p>
<p>It starts raining, and water gradually rises over time. At time <code>t</code>, the water level is <code>t</code>, meaning <strong>any</strong> cell with elevation less than equal to <code>t</code> is submerged or reachable.</p>

<p>Return <em>the least time until you can reach the bottom right square </em><code>(n - 1, n - 1)</code><em> if you start at the top left square </em><code>(0, 0)</code>.</p>
<p>You can swim from a square to another 4-directionally adjacent square if and only if the elevation of both squares individually are at most <code>t</code>. You can swim infinite distances in zero time. Of course, you must stay within the boundaries of the grid during your swim.</p>

<p>Return <em>the minimum time until you can reach the bottom right square </em><code>(n - 1, n - 1)</code><em> if you start at the top left square </em><code>(0, 0)</code>.</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 @@ -21,7 +21,7 @@ tags:

<p>有一个有 <code>n</code> 个节点的有向图,节点按 <code>0</code> 到 <code>n - 1</code> 编号。图由一个 <strong>索引从 0 开始</strong> 的 2D 整数数组&nbsp;<code>graph</code>表示,&nbsp;<code>graph[i]</code>是与节点 <code>i</code> 相邻的节点的整数数组,这意味着从节点 <code>i</code> 到&nbsp;<code>graph[i]</code>中的每个节点都有一条边。</p>

<p>如果一个节点没有连出的有向边,则该节点是 <strong>终端节点</strong> 。如果从该节点开始的所有可能路径都通向 <strong>终端节点</strong> ,则该节点为 <strong>终端节点</strong>(或另一个安全节点)。</p>
<p>如果一个节点没有连出的有向边,则该节点是 <strong>终端节点</strong> 。如果从该节点开始的所有可能路径都通向 <strong>终端节点</strong>(或另一个安全节点),则该节点为 <strong>安全节点</strong>。</p>

<p>返回一个由图中所有 <strong>安全节点</strong> 组成的数组作为答案。答案数组中的元素应当按 <strong>升序</strong> 排列。</p>

Expand Down
1 change: 1 addition & 0 deletions solution/0800-0899/0854.K-Similar Strings/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0800-0899/0854.K-Similar%20Strings/README.md
tags:
- 广度优先搜索
- 哈希表
- 字符串
---

Expand Down
1 change: 1 addition & 0 deletions solution/0800-0899/0854.K-Similar Strings/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0800-0899/0854.K-Similar%20Strings/README_EN.md
tags:
- Breadth-First Search
- Hash Table
- String
---

Expand Down
Loading
Loading