Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1316a46

Browse files
feat: update lc problems (#3881)
1 parent b26ca5e commit 1316a46

File tree

13 files changed

+61
-56
lines changed

13 files changed

+61
-56
lines changed

‎solution/0200-0299/0222.Count Complete Tree Nodes/README.md‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ tags:
2121

2222
<p>给你一棵<strong> 完全二叉树</strong> 的根节点 <code>root</code> ,求出该树的节点个数。</p>
2323

24-
<p><a href="https://baike.baidu.com/item/%E5%AE%8C%E5%85%A8%E4%BA%8C%E5%8F%89%E6%A0%91/7773232?fr=aladdin">完全二叉树</a> 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 <code>h</code> 层,则该层包含 <code>1~2<sup>h</sup></code>个节点。</p>
24+
<p><a href="https://baike.baidu.com/item/%E5%AE%8C%E5%85%A8%E4%BA%8C%E5%8F%89%E6%A0%91/7773232?fr=aladdin">完全二叉树</a> 的定义如下:在完全二叉树中,除了最底层节点可能没填满外,其余每层节点数都达到最大值,并且最下面一层的节点都集中在该层最左边的若干位置。若最底层为第 <code>h</code> 层(从第 0 层开始),则该层包含 <code>1~&nbsp;2<sup>h</sup></code>&nbsp;个节点。</p>
2525

26-
<p></p>
26+
<p>&nbsp;</p>
2727

2828
<p><strong>示例 1:</strong></p>
2929
<img alt="" src="https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/0200-0299/0222.Count%20Complete%20Tree%20Nodes/images/complete.jpg" style="width: 372px; height: 302px;" />
@@ -46,17 +46,17 @@ tags:
4646
<strong>输出:</strong>1
4747
</pre>
4848

49-
<p></p>
49+
<p>&nbsp;</p>
5050

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

5353
<ul>
5454
<li>树中节点的数目范围是<code>[0, 5 * 10<sup>4</sup>]</code></li>
55-
<li><code>0 <= Node.val <= 5 * 10<sup>4</sup></code></li>
55+
<li><code>0 &lt;= Node.val &lt;= 5 * 10<sup>4</sup></code></li>
5656
<li>题目数据保证输入的树是 <strong>完全二叉树</strong></li>
5757
</ul>
5858

59-
<p></p>
59+
<p>&nbsp;</p>
6060

6161
<p><strong>进阶:</strong>遍历树来统计节点是一种时间复杂度为 <code>O(n)</code> 的简单解决方案。你可以设计一个更快的算法吗?</p>
6262

‎solution/0300-0399/0321.Create Maximum Number/README_EN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ tags:
5757
<li><code>1 &lt;= m, n &lt;= 500</code></li>
5858
<li><code>0 &lt;= nums1[i], nums2[i] &lt;= 9</code></li>
5959
<li><code>1 &lt;= k &lt;= m + n</code></li>
60+
<li><code>nums1</code> and <code>nums2</code> do not have leading zeros.</li>
6061
</ul>
6162

6263
<!-- description:end -->

‎solution/0600-0699/0634.Find the Derangement of An Array/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0634.Fi
55
tags:
66
- 数学
77
- 动态规划
8+
- 组合数学
89
---
910

1011
<!-- problem:start -->

‎solution/0600-0699/0634.Find the Derangement of An Array/README_EN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0634.Fi
55
tags:
66
- Math
77
- Dynamic Programming
8+
- Combinatorics
89
---
910

1011
<!-- problem:start -->

‎solution/0700-0799/0735.Asteroid Collision/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ tags:
1818

1919
<!-- description:start -->
2020

21-
<p>We are given an array <code>asteroids</code> of integers representing asteroids in a row.</p>
21+
<p>We are given an array <code>asteroids</code> of integers representing asteroids in a row. The indices of the asteriod in the array represent their relative position in space.</p>
2222

2323
<p>For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed.</p>
2424

‎solution/0900-0999/0977.Squares of a Sorted Array/README.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tags:
2323
<ul>
2424
</ul>
2525

26-
<p></p>
26+
<p>&nbsp;</p>
2727

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

@@ -40,22 +40,22 @@ tags:
4040
<strong>输出:</strong>[4,9,9,49,121]
4141
</pre>
4242

43-
<p></p>
43+
<p>&nbsp;</p>
4444

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

4747
<ul>
48-
<li><code><span>1 <= nums.length <= </span>10<sup>4</sup></code></li>
49-
<li><code>-10<sup>4</sup> <= nums[i] <= 10<sup>4</sup></code></li>
48+
<li><code><span>1 &lt;= nums.length &lt;= </span>10<sup>4</sup></code></li>
49+
<li><code>-10<sup>4</sup> &lt;= nums[i] &lt;= 10<sup>4</sup></code></li>
5050
<li><code>nums</code> 已按 <strong>非递减顺序</strong> 排序</li>
5151
</ul>
5252

53-
<p></p>
53+
<p>&nbsp;</p>
5454

5555
<p><strong>进阶:</strong></p>
5656

5757
<ul>
58-
<li>请你<span style="color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Helvetica, Arial, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">设计时间复杂度为 <code>O(n)</code> 的算法解决本问题</span></li>
58+
<li>请你设计时间复杂度为 <code>O(n)</code> 的算法解决本问题</li>
5959
</ul>
6060

6161
<!-- description:end -->

‎solution/1800-1899/1891.Cutting Ribbons/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ tags:
2929
<li>切割成四条长度为 <code>1</code>&nbsp;的绳子。</li>
3030
</ul>
3131

32-
<p>你的任务是找出最大 <code>x</code> 值,要求满足可以裁切出恰好 <code>k</code> 条长度均为 <code>x</code> 的绳子。你可以丢弃裁切后剩余的任意长度的绳子。如果不可能切割出&nbsp;<code>k</code> 条相同长度的绳子,返回 0。</p>
32+
<p>你的任务是找出最大 <code>x</code> 值,要求满足可以裁切出至少&nbsp;<code>k</code> 条长度均为 <code>x</code> 的绳子。你可以丢弃裁切后剩余的任意长度的绳子。如果不可能切割出&nbsp;<code>k</code> 条相同长度的绳子,返回 0。</p>
3333

3434
<p>&nbsp;</p>
3535

‎solution/2500-2599/2558.Take Gifts From the Richest Pile/README_EN.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ tags:
2525
<ul>
2626
<li>Choose the pile with the maximum number of gifts.</li>
2727
<li>If there is more than one pile with the maximum number of gifts, choose any.</li>
28-
<li>Leave behind the floor of the square root of the number of gifts in the pile. Take the rest of the gifts.</li>
28+
<li>Reduce the number of gifts in the pile to the floor of the square root of the original number of gifts in the pile.</li>
2929
</ul>
3030

3131
<p>Return <em>the number of gifts remaining after </em><code>k</code><em> seconds.</em></p>

‎solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README.md‎

Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,70 +6,72 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De
66

77
<!-- problem:start -->
88

9-
# [3391. Design a 3D Binary Matrix with Efficient Layer Tracking 🔒](https://leetcode.cn/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking)
9+
# [3391. 设计一个高效的层跟踪三维二进制矩阵 🔒](https://leetcode.cn/problems/design-a-3d-binary-matrix-with-efficient-layer-tracking)
1010

1111
[English Version](/solution/3300-3399/3391.Design%20a%203D%20Binary%20Matrix%20with%20Efficient%20Layer%20Tracking/README_EN.md)
1212

1313
## 题目描述
1414

1515
<!-- description:start -->
1616

17-
<p>You are given a <code>n x n x n</code> <strong>binary</strong> 3D array <code>matrix</code>.</p>
17+
<p>给定一个&nbsp;<code>n x n x n</code>&nbsp; <strong>二进制&nbsp;</strong>三维数组&nbsp;<code>matrix</code></p>
1818

19-
<p>Implement the <code>matrix3D</code> class:</p>
19+
<p>实现&nbsp;<code>Matrix3D</code>&nbsp;类:</p>
2020

2121
<ul>
22-
<li><code>matrix3D(int n)</code> Initializes the object with the 3D binary array <code>matrix</code>, where <strong>all</strong> elements are initially set to 0.</li>
23-
<li><code>void setCell(int x, int y, int z)</code> Sets the value at <code>matrix[x][y][z]</code> to 1.</li>
24-
<li><code>void unsetCell(int x, int y, int z)</code> Sets the value at <code>matrix[x][y][z]</code> to 0.</li>
25-
<li><code>int largestMatrix()</code> Returns the index <code>x</code> where <code>matrix[x]</code> contains the most number of 1&#39;s. If there are multiple such indices, return the <strong>largest</strong><code>x</code>.</li>
22+
<li><code>Matrix3D(int n)</code>&nbsp;用三维二进制数组&nbsp;<code>matrix</code>&nbsp;初始化对象,其中 <strong>所有</strong>&nbsp;元素都初始化为 0。</li>
23+
<li><code>void setCell(int x, int y, int z)</code>&nbsp;将 <code>matrix[x][y][z]</code>&nbsp;的值设为 1。</li>
24+
<li><code>void unsetCell(int x, int y, int z)</code>&nbsp;将 <code>matrix[x][y][z]</code>&nbsp;的值设为 0。</li>
25+
<li><code>int largestMatrix()</code>&nbsp;返回包含最多 1 的 <code>matrix[x]</code>&nbsp;的下标&nbsp;<code>x</code>。如果这样的对应值有多个,返回&nbsp;<strong>最大的</strong>&nbsp;<code>x</code></li>
2626
</ul>
2727

2828
<p>&nbsp;</p>
29-
<p><strong class="example">Example 1:</strong></p>
29+
30+
<p><strong class="example">示例 1:</strong></p>
3031

3132
<div class="example-block">
32-
<p><strong>Input:</strong><br />
33-
<span class="example-io">[&quot;matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;]<br />
33+
<p><strong>输入:</strong><br />
34+
<span class="example-io">["Matrix3D", "setCell", "largestMatrix", "setCell", "largestMatrix", "setCell", "largestMatrix"]<br />
3435
[[3], [0, 0, 0], [], [1, 1, 2], [], [0, 0, 1], []]</span></p>
3536

36-
<p><strong>Output:</strong><br />
37+
<p><strong>输出:</strong><br />
3738
<span class="example-io">[null, null, 0, null, 1, null, 0] </span></p>
3839

39-
<p><strong>Explanation</strong></p>
40-
matrix3D matrix3D = new matrix3D(3); // Initializes a <code>3 x 3 x 3</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
41-
matrix3D.setCell(0, 0, 0); // Sets <code>matrix[0][0][0]</code> to 1.<br />
42-
matrix3D.largestMatrix(); // Returns 0. <code>matrix[0]</code> has the most number of 1&#39;s.<br />
43-
matrix3D.setCell(1, 1, 2); // Sets <code>matrix[1][1][2]</code> to 1.<br />
44-
matrix3D.largestMatrix(); // Returns 1. <code>matrix[0]</code> and <code>matrix[1]</code> tie with the most number of 1&#39;s, but index 1 is bigger.<br />
45-
matrix3D.setCell(0, 0, 1); // Sets <code>matrix[0][0][1]</code> to 1.<br />
46-
matrix3D.largestMatrix(); // Returns 0. <code>matrix[0]</code> has the most number of 1&#39;s.</div>
40+
<p><strong>解释:</strong></p>
41+
Matrix3D matrix3D = new Matrix3D(3); // 初始化一个&nbsp;<code>3 x 3 x 3</code>&nbsp;的三维数组&nbsp;<code>matrix</code>,用全 0 填充。<br />
42+
matrix3D.setCell(0, 0, 0); // &nbsp;<code>matrix[0][0][0]</code> 设为 1。<br />
43+
matrix3D.largestMatrix(); // 返回 0。<code>matrix[0]</code>&nbsp;1 的数量最多。<br />
44+
matrix3D.setCell(1, 1, 2); // <code>matrix[1][1][2]</code> 设为 1。<br />
45+
matrix3D.largestMatrix(); // 返回 1。<code>matrix[0]</code> &nbsp;<code>matrix[1]</code>&nbsp;1 的数量一样多,但下标 1 更大。<br />
46+
matrix3D.setCell(0, 0, 1); // <code>matrix[0][0][1]</code> 设为 1。<br />
47+
matrix3D.largestMatrix(); // 返回 0。<code>matrix[0]</code>&nbsp;1 的数量最多。</div>
4748

48-
<p><strong class="example">Example 2:</strong></p>
49+
<p><strong class="example">示例 2:</strong></p>
4950

5051
<div class="example-block">
51-
<p><strong>Input:</strong><br />
52-
<span class="example-io">[&quot;matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;unsetCell&quot;, &quot;largestMatrix&quot;]<br />
52+
<p><strong>输入:</strong><br />
53+
<span class="example-io">["Matrix3D", "setCell", "largestMatrix", "unsetCell", "largestMatrix"]<br />
5354
[[4], [2, 1, 1], [], [2, 1, 1], []]</span></p>
5455

55-
<p><strong>Output:</strong><br />
56+
<p><strong>输出:</strong><br />
5657
<span class="example-io">[null, null, 2, null, 3] </span></p>
5758

58-
<p><strong>Explanation</strong></p>
59-
matrix3D matrix3D = new matrix3D(4); // Initializes a <code>4 x 4 x 4</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
60-
matrix3D.setCell(2, 1, 1); // Sets <code>matrix[2][1][1]</code> to 1.<br />
61-
matrix3D.largestMatrix(); // Returns 2. <code>matrix[2]</code> has the most number of 1&#39;s.<br />
62-
matrix3D.unsetCell(2, 1, 1); // Sets <code>matrix[2][1][1]</code> to 0.<br />
63-
matrix3D.largestMatrix(); // Returns 3. All indices from 0 to 3 tie with the same number of 1&#39;s, but index 3 is the biggest.</div>
59+
<p><strong>解释:</strong></p>
60+
Matrix3D matrix3D = new matrix3D(4); // 初始化一个&nbsp;<code>4 x 4 x 4</code>&nbsp;的三维数组&nbsp;<code>matrix</code>,用全 0 填充。<br />
61+
matrix3D.setCell(2, 1, 1); // &nbsp;<code>matrix[2][1][1]</code> 设为 1。<br />
62+
matrix3D.largestMatrix(); // 返回 2。<code>matrix[2]</code>&nbsp;1 的数量最多。<br />
63+
matrix3D.unsetCell(2, 1, 1); // <code>matrix[2][1][1]</code> 设为 0。<br />
64+
matrix3D.largestMatrix(); // 返回 3。0 到 3 的对应值都有相同数量的 1,但下标 3 最大。</div>
6465

6566
<p>&nbsp;</p>
66-
<p><strong>Constraints:</strong></p>
67+
68+
<p><strong>提示:</strong></p>
6769

6870
<ul>
6971
<li><code>1 &lt;= n &lt;= 100</code></li>
7072
<li><code>0 &lt;= x, y, z &lt; n</code></li>
71-
<li>At most <code>10<sup>5</sup></code> calls are made in total to <code>setCell</code> and <code>unsetCell</code>.</li>
72-
<li>At most <code>10<sup>4</sup></code> calls are made to <code>largestMatrix</code>.</li>
73+
<li>最多总共调用&nbsp;<code>10<sup>5</sup></code>&nbsp;次&nbsp;<code>setCell</code> 和&nbsp;<code>unsetCell</code></li>
74+
<li>最多调用&nbsp;<code>10<sup>4</sup></code> 次&nbsp;<code>largestMatrix</code></li>
7375
</ul>
7476

7577
<!-- description:end -->

‎solution/3300-3399/3391.Design a 3D Binary Matrix with Efficient Layer Tracking/README_EN.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De
1616

1717
<p>You are given a <code>n x n x n</code> <strong>binary</strong> 3D array <code>matrix</code>.</p>
1818

19-
<p>Implement the <code>matrix3D</code> class:</p>
19+
<p>Implement the <code>Matrix3D</code> class:</p>
2020

2121
<ul>
22-
<li><code>matrix3D(int n)</code> Initializes the object with the 3D binary array <code>matrix</code>, where <strong>all</strong> elements are initially set to 0.</li>
22+
<li><code>Matrix3D(int n)</code> Initializes the object with the 3D binary array <code>matrix</code>, where <strong>all</strong> elements are initially set to 0.</li>
2323
<li><code>void setCell(int x, int y, int z)</code> Sets the value at <code>matrix[x][y][z]</code> to 1.</li>
2424
<li><code>void unsetCell(int x, int y, int z)</code> Sets the value at <code>matrix[x][y][z]</code> to 0.</li>
2525
<li><code>int largestMatrix()</code> Returns the index <code>x</code> where <code>matrix[x]</code> contains the most number of 1&#39;s. If there are multiple such indices, return the <strong>largest</strong> <code>x</code>.</li>
@@ -30,14 +30,14 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3391.De
3030

3131
<div class="example-block">
3232
<p><strong>Input:</strong><br />
33-
<span class="example-io">[&quot;matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;]<br />
33+
<span class="example-io">[&quot;Matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;]<br />
3434
[[3], [0, 0, 0], [], [1, 1, 2], [], [0, 0, 1], []]</span></p>
3535

3636
<p><strong>Output:</strong><br />
3737
<span class="example-io">[null, null, 0, null, 1, null, 0] </span></p>
3838

3939
<p><strong>Explanation</strong></p>
40-
matrix3D matrix3D = new matrix3D(3); // Initializes a <code>3 x 3 x 3</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
40+
Matrix3D matrix3D = new Matrix3D(3); // Initializes a <code>3 x 3 x 3</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
4141
matrix3D.setCell(0, 0, 0); // Sets <code>matrix[0][0][0]</code> to 1.<br />
4242
matrix3D.largestMatrix(); // Returns 0. <code>matrix[0]</code> has the most number of 1&#39;s.<br />
4343
matrix3D.setCell(1, 1, 2); // Sets <code>matrix[1][1][2]</code> to 1.<br />
@@ -49,14 +49,14 @@ matrix3D.largestMatrix(); // Returns 0. <code>matrix[0]</code> has the most numb
4949

5050
<div class="example-block">
5151
<p><strong>Input:</strong><br />
52-
<span class="example-io">[&quot;matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;unsetCell&quot;, &quot;largestMatrix&quot;]<br />
52+
<span class="example-io">[&quot;Matrix3D&quot;, &quot;setCell&quot;, &quot;largestMatrix&quot;, &quot;unsetCell&quot;, &quot;largestMatrix&quot;]<br />
5353
[[4], [2, 1, 1], [], [2, 1, 1], []]</span></p>
5454

5555
<p><strong>Output:</strong><br />
5656
<span class="example-io">[null, null, 2, null, 3] </span></p>
5757

5858
<p><strong>Explanation</strong></p>
59-
matrix3D matrix3D = new matrix3D(4); // Initializes a <code>4 x 4 x 4</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
59+
Matrix3D matrix3D = new Matrix3D(4); // Initializes a <code>4 x 4 x 4</code> 3D array <code>matrix</code>, filled with all 0&#39;s.<br />
6060
matrix3D.setCell(2, 1, 1); // Sets <code>matrix[2][1][1]</code> to 1.<br />
6161
matrix3D.largestMatrix(); // Returns 2. <code>matrix[2]</code> has the most number of 1&#39;s.<br />
6262
matrix3D.unsetCell(2, 1, 1); // Sets <code>matrix[2][1][1]</code> to 0.<br />

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /