Skip to content

Commit 0e94a77

Browse files
authored
feat: update lc problems (#4985)
1 parent 4b4c2e0 commit 0e94a77

25 files changed

Lines changed: 184 additions & 81 deletions

File tree

solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,29 @@ function minBitwiseArray(nums: number[]): number[] {
201201
}
202202
```
203203

204+
#### Rust
205+
206+
```rust
207+
impl Solution {
208+
pub fn min_bitwise_array(nums: Vec<i32>) -> Vec<i32> {
209+
let mut ans: Vec<i32> = Vec::new();
210+
for x in nums {
211+
if x == 2 {
212+
ans.push(-1);
213+
} else {
214+
for i in 1..32 {
215+
if (((x >> i) & 1) ^ 1) != 0 {
216+
ans.push(x ^ (1 << (i - 1)));
217+
break;
218+
}
219+
}
220+
}
221+
}
222+
ans
223+
}
224+
}
225+
```
226+
204227
<!-- tabs:end -->
205228

206229
<!-- solution:end -->

solution/3300-3399/3315.Construct the Minimum Bitwise Array II/README_EN.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,29 @@ function minBitwiseArray(nums: number[]): number[] {
195195
}
196196
```
197197

198+
#### Rust
199+
200+
```rust
201+
impl Solution {
202+
pub fn min_bitwise_array(nums: Vec<i32>) -> Vec<i32> {
203+
let mut ans: Vec<i32> = Vec::new();
204+
for x in nums {
205+
if x == 2 {
206+
ans.push(-1);
207+
} else {
208+
for i in 1..32 {
209+
if (((x >> i) & 1) ^ 1) != 0 {
210+
ans.push(x ^ (1 << (i - 1)));
211+
break;
212+
}
213+
}
214+
}
215+
}
216+
ans
217+
}
218+
}
219+
```
220+
198221
<!-- tabs:end -->
199222

200223
<!-- solution:end -->
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
impl Solution {
2+
pub fn min_bitwise_array(nums: Vec<i32>) -> Vec<i32> {
3+
let mut ans: Vec<i32> = Vec::new();
4+
for x in nums {
5+
if x == 2 {
6+
ans.push(-1);
7+
} else {
8+
for i in 1..32 {
9+
if (((x >> i) & 1) ^ 1) != 0 {
10+
ans.push(x ^ (1 << (i - 1)));
11+
break;
12+
}
13+
}
14+
}
15+
}
16+
ans
17+
}
18+
}

solution/3800-3899/3803.Count Residue Prefixes/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3803.Count%20Residue%20Prefixes/README.md
55
rating: 1248
66
source: 第 484 场周赛 Q1
7+
tags:
8+
- 哈希表
9+
- 字符串
710
---
811

912
<!-- problem:start -->

solution/3800-3899/3803.Count Residue Prefixes/README_EN.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3803.Count%20Residue%20Prefixes/README_EN.md
55
rating: 1248
66
source: Weekly Contest 484 Q1
7+
tags:
8+
- Hash Table
9+
- String
710
---
811

912
<!-- problem:start -->

solution/3800-3899/3804.Number of Centered Subarrays/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3804.Number%20of%20Centered%20Subarrays/README.md
55
rating: 1393
66
source: 第 484 场周赛 Q2
7+
tags:
8+
- 数组
9+
- 哈希表
10+
- 枚举
711
---
812

913
<!-- problem:start -->

solution/3800-3899/3804.Number of Centered Subarrays/README_EN.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3804.Number%20of%20Centered%20Subarrays/README_EN.md
55
rating: 1393
66
source: Weekly Contest 484 Q2
7+
tags:
8+
- Array
9+
- Hash Table
10+
- Enumeration
711
---
812

913
<!-- problem:start -->

solution/3800-3899/3805.Count Caesar Cipher Pairs/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3805.Count%20Caesar%20Cipher%20Pairs/README.md
55
rating: 1624
66
source: 第 484 场周赛 Q3
7+
tags:
8+
- 数组
9+
- 哈希表
10+
- 数学
11+
- 字符串
12+
- 计数
713
---
814

915
<!-- problem:start -->

solution/3800-3899/3805.Count Caesar Cipher Pairs/README_EN.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ difficulty: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3805.Count%20Caesar%20Cipher%20Pairs/README_EN.md
55
rating: 1624
66
source: Weekly Contest 484 Q3
7+
tags:
8+
- Array
9+
- Hash Table
10+
- Math
11+
- String
12+
- Counting
713
---
814

915
<!-- problem:start -->

solution/3800-3899/3806.Maximum Bitwise AND After Increment Operations/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ difficulty: 困难
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3800-3899/3806.Maximum%20Bitwise%20AND%20After%20Increment%20Operations/README.md
55
rating: 2259
66
source: 第 484 场周赛 Q4
7+
tags:
8+
- 贪心
9+
- 位运算
10+
- 数组
11+
- 排序
712
---
813

914
<!-- problem:start -->

0 commit comments

Comments
 (0)