Skip to content

Commit 299056a

Browse files
authored
feat: add weekly contest 480 (#4901)
1 parent f47e239 commit 299056a

File tree

95 files changed

+2702
-264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+2702
-264
lines changed

README.md

Lines changed: 124 additions & 124 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"clang-format": "^1.8.0",
1010
"husky": "^9.1.7",
1111
"lint-staged": "^15.2.10",
12-
"prettier": "^3.4.2",
12+
"prettier": "^3.3.2",
1313
"prettier-plugin-sql-cst": "^0.14.0"
1414
},
1515
"lint-staged": {

solution/0000-0099/0092.Reverse Linked List II/README.md

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

1717
<!-- description:start -->
1818

19-
给你单链表的头指针 <code>head</code> 和两个整数 <code>left</code> 和 <code>right</code> ,其中 <code>left <= right</code> 。请你反转从位置 <code>left</code> 到位置 <code>right</code> 的链表节点,返回 <strong>反转后的链表</strong> 。
19+
给你单链表的头指针 <code>head</code> 和两个整数  <code>left</code> 和 <code>right</code> ,其中  <code>left <= right</code> 。请你反转从位置 <code>left</code> 到位置 <code>right</code> 的链表节点,返回 <strong>反转后的链表</strong> 。
2020

2121
<p> </p>
2222

solution/0100-0199/0177.Nth Highest Salary/README.md

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

99
<!-- problem:start -->
1010

11-
# [177. 第N高的薪水](https://leetcode.cn/problems/nth-highest-salary)
11+
# [177. 第 N 高的薪水](https://leetcode.cn/problems/nth-highest-salary)
1212

1313
[English Version](/solution/0100-0199/0177.Nth%20Highest%20Salary/README_EN.md)
1414

solution/0100-0199/0187.Repeated DNA Sequences/README.md

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

1414
<!-- problem:start -->
1515

16-
# [187. 重复的DNA序列](https://leetcode.cn/problems/repeated-dna-sequences)
16+
# [187. 重复的 DNA 序列](https://leetcode.cn/problems/repeated-dna-sequences)
1717

1818
[English Version](/solution/0100-0199/0187.Repeated%20DNA%20Sequences/README_EN.md)
1919

solution/0100-0199/0191.Number of 1 Bits/README.md

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

1010
<!-- problem:start -->
1111

12-
# [191. 位1的个数](https://leetcode.cn/problems/number-of-1-bits)
12+
# [191. 位 1 的个数](https://leetcode.cn/problems/number-of-1-bits)
1313

1414
[English Version](/solution/0100-0199/0191.Number%20of%201%20Bits/README_EN.md)
1515

solution/0200-0299/0215.Kth Largest Element in an Array/README.md

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

1313
<!-- problem:start -->
1414

15-
# [215. 数组中的第K个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array)
15+
# [215. 数组中的第 K 个最大元素](https://leetcode.cn/problems/kth-largest-element-in-an-array)
1616

1717
[English Version](/solution/0200-0299/0215.Kth%20Largest%20Element%20in%20an%20Array/README_EN.md)
1818

solution/0300-0399/0342.Power of Four/README.md

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

1111
<!-- problem:start -->
1212

13-
# [342. 4的幂](https://leetcode.cn/problems/power-of-four)
13+
# [342. 4 的幂](https://leetcode.cn/problems/power-of-four)
1414

1515
[English Version](/solution/0300-0399/0342.Power%20of%20Four/README_EN.md)
1616

solution/0300-0399/0382.Linked List Random Node/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ solution.getRandom(); // 返回 3
4646
solution.getRandom(); // 返回 2
4747
solution.getRandom(); // 返回 2
4848
solution.getRandom(); // 返回 3
49-
// getRandom() 方法应随机返回 1、2、3中的一个,每个元素被返回的概率相等。</pre>
49+
// getRandom() 方法应随机返回 1、2、3 中的一个,每个元素被返回的概率相等。</pre>
5050

5151
<p>&nbsp;</p>
5252

solution/0400-0499/0440.K-th Smallest in Lexicographical Order/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ tags:
88

99
<!-- problem:start -->
1010

11-
# [440. 字典序的第K小数字](https://leetcode.cn/problems/k-th-smallest-in-lexicographical-order)
11+
# [440. 字典序的第 K 小数字](https://leetcode.cn/problems/k-th-smallest-in-lexicographical-order)
1212

1313
[English Version](/solution/0400-0499/0440.K-th%20Smallest%20in%20Lexicographical%20Order/README_EN.md)
1414

@@ -55,10 +55,10 @@ tags:
5555

5656
我们将 $[1, n]$ 看作一棵 **十叉字典树(Trie)**
5757

58-
- 每个节点是一个前缀,根节点为空串;
59-
- 节点的子节点是当前前缀拼接上 $0 \sim 9$;
60-
- 例如前缀 $1$ 会有子节点 $10, 11, \ldots, 19$,而 $10$ 会有 $100, 101, \ldots, 109$;
61-
- 这种结构天然符合字典序遍历。
58+
- 每个节点是一个前缀,根节点为空串;
59+
- 节点的子节点是当前前缀拼接上 $0 \sim 9$;
60+
- 例如前缀 $1$ 会有子节点 $10, 11, \ldots, 19$,而 $10$ 会有 $100, 101, \ldots, 109$;
61+
- 这种结构天然符合字典序遍历。
6262

6363
```
6464
@@ -74,8 +74,8 @@ tags:
7474

7575
每次我们计算当前前缀下有多少个合法数字(即以 $\textit{curr}$ 为前缀、且不超过 $n$ 的整数个数),记作 $\textit{count}(\text{curr})$:
7676

77-
- 如果 $k \ge \text{count}(\text{curr})$:说明目标不在这棵子树中,跳过整棵子树,前缀右移:$\textit{curr} \leftarrow \text{curr} + 1$,并更新 $k \leftarrow k - \text{count}(\text{curr})$;
78-
- 否则:说明目标在当前前缀的子树中,进入下一层:$\textit{curr} \leftarrow \text{curr} \times 10$,并消耗一个前缀:$k \leftarrow k - 1$。
77+
- 如果 $k \ge \text{count}(\text{curr})$:说明目标不在这棵子树中,跳过整棵子树,前缀右移:$\textit{curr} \leftarrow \text{curr} + 1$,并更新 $k \leftarrow k - \text{count}(\text{curr})$;
78+
- 否则:说明目标在当前前缀的子树中,进入下一层:$\textit{curr} \leftarrow \text{curr} \times 10$,并消耗一个前缀:$k \leftarrow k - 1$。
7979

8080
每一层我们将当前区间扩大 $10$ 倍,向下延伸到更长的前缀,直到超出 $n$。
8181

0 commit comments

Comments
 (0)