Skip to content

Commit 27129fd

Browse files
committed
docs: update code blocks
1 parent 87718b6 commit 27129fd

File tree

19 files changed

+29
-21
lines changed

19 files changed

+29
-21
lines changed

lcof/面试题03. 数组中重复的数字/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ function swap(nums: number[], i: number, j: number): void {
165165

166166
### **Rust**
167167

168-
```rs
168+
```rust
169169
impl Solution {
170170
pub fn find_repeat_number(mut nums: Vec<i32>) -> i32 {
171171
for i in 0..nums.len() {

lcof2/剑指 Offer II 035. 最小时间差/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939

4040
<!-- 这里可写通用的实现逻辑 -->
4141

42+
我们注意到,时间点最多只有 `24 * 60` 个,因此,当 timePoints 长度超过 `24 * 60`,说明有重复的时间点,提前返回 0。
43+
44+
接下来:
45+
4246
首先,遍历时间列表,将其转换为“分钟制”列表 `mins`,比如,对于时间点 `13:14`,将其转换为 `13 * 60 + 14`
4347

4448
接着将“分钟制”列表按升序排列,然后将此列表的最小时间 `mins[0]` 加上 `24 * 60` 追加至列表尾部,用于处理最大值、最小值的差值这种特殊情况。

solution/0000-0099/0026.Remove Duplicates from Sorted Array/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ for (int i = 0; i < len; i++) {
6565

6666
原问题要求最多相同的数字最多出现 1 次,我们可以扩展至相同的数字最多保留 k 个。
6767

68-
- 由于相同的数字最多保留 k 个,那么原数组的前 k 个元素我们可以直接保留;
69-
- 对于后面的数字,能够保留的前提是:当前数字 num 与前面已保留的数字的倒数第 k 个元素比较,不同则保留,相同则跳过。
68+
- 由于相同的数字最多保留 k 个,那么原数组的前 k 个元素我们可以直接保留;
69+
- 对于后面的数字,能够保留的前提是:当前数字 num 与前面已保留的数字的倒数第 k 个元素比较,不同则保留,相同则跳过。
7070

7171
相似题目:[80. 删除有序数组中的重复项 II](/solution/0000-0099/0080.Remove%20Duplicates%20from%20Sorted%20Array%20II/README.md)
7272

@@ -173,7 +173,7 @@ public class Solution {
173173

174174
### **Rust**
175175

176-
```rs
176+
```rust
177177
impl Solution {
178178
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
179179
let mut len = 0;

solution/0000-0099/0026.Remove Duplicates from Sorted Array/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ public class Solution {
153153

154154
### **Rust**
155155

156-
```rs
156+
```rust
157157
impl Solution {
158158
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
159159
let mut len = 0;

solution/0000-0099/0027.Remove Element/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func removeElement(nums []int, val int) int {
153153

154154
### **Rust**
155155

156-
```rs
156+
```rust
157157
impl Solution {
158158
pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
159159
let mut len = 0;

solution/0000-0099/0027.Remove Element/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ func removeElement(nums []int, val int) int {
141141

142142
### **Rust**
143143

144-
```rs
144+
```rust
145145
impl Solution {
146146
pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
147147
let mut len = 0;

solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ for (int i = 0; i < len; i++) {
6565

6666
原问题要求最多相同的数字最多出现 2 次,我们可以扩展至相同的数字最多保留 k 个。
6767

68-
- 由于相同的数字最多保留 k 个,那么原数组的前 k 个元素我们可以直接保留;
69-
- 对于后面的数字,能够保留的前提是:当前数字 num 与前面已保留的数字的倒数第 k 个元素比较,不同则保留,相同则跳过。
68+
- 由于相同的数字最多保留 k 个,那么原数组的前 k 个元素我们可以直接保留;
69+
- 对于后面的数字,能够保留的前提是:当前数字 num 与前面已保留的数字的倒数第 k 个元素比较,不同则保留,相同则跳过。
7070

7171
相似题目:[26. 删除有序数组中的重复项](/solution/0000-0099/0026.Remove%20Duplicates%20from%20Sorted%20Array/README.md)
7272

@@ -173,7 +173,7 @@ func removeDuplicates(nums []int) int {
173173

174174
### **Rust**
175175

176-
```rs
176+
```rust
177177
impl Solution {
178178
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
179179
let mut len = 0;

solution/0000-0099/0080.Remove Duplicates from Sorted Array II/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func removeDuplicates(nums []int) int {
154154

155155
### **Rust**
156156

157-
```rs
157+
```rust
158158
impl Solution {
159159
pub fn remove_duplicates(nums: &mut Vec<i32>) -> i32 {
160160
let mut len = 0;

solution/0100-0199/0169.Majority Element/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ func majorityElement(nums []int) int {
167167

168168
### **Rust**
169169

170-
```rs
170+
```rust
171171
impl Solution {
172172
pub fn majority_element(nums: Vec<i32>) -> i32 {
173173
let mut major = 0;

solution/0100-0199/0169.Majority Element/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func majorityElement(nums []int) int {
154154

155155
### **Rust**
156156

157-
```rs
157+
```rust
158158
impl Solution {
159159
pub fn majority_element(nums: Vec<i32>) -> i32 {
160160
let mut major = 0;

solution/0100-0199/0189.Rotate Array/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func reverse(nums []int, i, j int) {
159159

160160
### **Rust**
161161

162-
```rs
162+
```rust
163163
impl Solution {
164164
pub fn rotate(nums: &mut Vec<i32>, k: i32) {
165165
let n = nums.len();

solution/0100-0199/0189.Rotate Array/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func reverse(nums []int, i, j int) {
134134

135135
### **Rust**
136136

137-
```rs
137+
```rust
138138
impl Solution {
139139
pub fn rotate(nums: &mut Vec<i32>, k: i32) {
140140
let n = nums.len();

solution/0200-0299/0283.Move Zeroes/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ var moveZeroes = function (nums) {
117117

118118
### **Rust**
119119

120-
```rs
120+
```rust
121121
impl Solution {
122122
pub fn move_zeroes(nums: &mut Vec<i32>) {
123123
let mut i = 0;

solution/0200-0299/0283.Move Zeroes/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ var moveZeroes = function (nums) {
118118

119119
### **Rust**
120120

121-
```rs
121+
```rust
122122
impl Solution {
123123
pub fn move_zeroes(nums: &mut Vec<i32>) {
124124
let mut i = 0;

solution/0500-0599/0528.Random Pick with Weight/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Solution.prototype.pickIndex = function () {
252252

253253
### **Rust**
254254

255-
```rs
255+
```rust
256256
use rand::{thread_rng, Rng};
257257

258258
struct Solution {

solution/0500-0599/0528.Random Pick with Weight/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Solution.prototype.pickIndex = function () {
242242

243243
### **Rust**
244244

245-
```rs
245+
```rust
246246
use rand::{thread_rng, Rng};
247247

248248
struct Solution {

solution/0500-0599/0539.Minimum Time Difference/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737

3838
<!-- 这里可写通用的实现逻辑 -->
3939

40+
我们注意到,时间点最多只有 `24 * 60` 个,因此,当 timePoints 长度超过 `24 * 60`,说明有重复的时间点,提前返回 0。
41+
42+
接下来:
43+
4044
首先,遍历时间列表,将其转换为“分钟制”列表 `mins`,比如,对于时间点 `13:14`,将其转换为 `13 * 60 + 14`
4145

4246
接着将“分钟制”列表按升序排列,然后将此列表的最小时间 `mins[0]` 加上 `24 * 60` 追加至列表尾部,用于处理最大值、最小值的差值这种特殊情况。

solution/1000-1099/1036.Escape a Large Maze/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ func isEscapePossible(blocked [][]int, source []int, target []int) bool {
188188

189189
### **Rust**
190190

191-
```rs
191+
```rust
192192
use std::collections::{HashSet, VecDeque};
193193

194194
const BOUNDARY: i32 = 1_000_000;

solution/1000-1099/1036.Escape a Large Maze/README_EN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ func isEscapePossible(blocked [][]int, source []int, target []int) bool {
177177

178178
### **Rust**
179179

180-
```rs
180+
```rust
181181
use std::collections::{HashSet, VecDeque};
182182

183183
const BOUNDARY: i32 = 1_000_000;

0 commit comments

Comments
 (0)