Skip to content

Commit 5080d41

Browse files
authored
feat: add rust solution to lc problem: No.2529 (#1260)
Signed-off-by: xiaolatiao <1628652790@qq.com>
1 parent 1c4c142 commit 5080d41

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

solution/2500-2599/2529.Maximum Count of Positive Integer and Negative Integer/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,25 @@ impl Solution {
287287
}
288288
```
289289

290+
```rust
291+
impl Solution {
292+
pub fn maximum_count(nums: Vec<i32>) -> i32 {
293+
let mut a = 0;
294+
let mut b = 0;
295+
296+
for n in nums {
297+
if n > 0 {
298+
a += 1;
299+
} else if n < 0 {
300+
b += 1
301+
}
302+
}
303+
304+
std::cmp::max(a, b)
305+
}
306+
}
307+
```
308+
290309
### **C**
291310

292311
```c

solution/2500-2599/2529.Maximum Count of Positive Integer and Negative Integer/README_EN.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,25 @@ impl Solution {
264264
}
265265
```
266266

267+
```rust
268+
impl Solution {
269+
pub fn maximum_count(nums: Vec<i32>) -> i32 {
270+
let mut a = 0;
271+
let mut b = 0;
272+
273+
for n in nums {
274+
if n > 0 {
275+
a += 1;
276+
} else if n < 0 {
277+
b += 1
278+
}
279+
}
280+
281+
std::cmp::max(a, b)
282+
}
283+
}
284+
```
285+
267286
### **C**
268287

269288
```c

0 commit comments

Comments
 (0)