• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

EFanZh / LeetCode / 21864245012

20 Feb 2026 01:54PM UTC coverage: 99.884% (-0.001%) from 99.885%
21864245012

push

github

EFanZh
Add problem 3354: Make Array Elements Equal to Zero

296 of 296 branches covered (100.0%)

Branch coverage included in aggregate %.

25 of 26 new or added lines in 2 files covered. (96.15%)

121842 of 121984 relevant lines covered (99.88%)

7782.39 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/src/problem_3354_make_array_elements_equal_to_zero/iterative.rs
1
pub struct Solution;
2

3
// ------------------------------------------------------ snip ------------------------------------------------------ //
4

5
impl Solution {
6
    pub fn count_valid_selections(nums: Vec<i32>) -> i32 {
2✔
7
        let mut diff = nums.iter().sum::<i32>();
2✔
8
        let mut result = 0;
2✔
9

10
        for num in nums {
9✔
11
            if num == 0 {
9✔
12
                result += match diff {
3✔
NEW
13
                    -1 | 1 => 1,
×
14
                    0 => 2,
1✔
15
                    ..-1 => break,
2✔
16
                    _ => continue,
1✔
17
                }
18
            } else {
6✔
19
                diff -= num * 2;
6✔
20
            }
6✔
21
        }
22

23
        result
2✔
24
    }
2✔
25
}
26

27
// ------------------------------------------------------ snip ------------------------------------------------------ //
28

29
impl super::Solution for Solution {
30
    fn count_valid_selections(nums: Vec<i32>) -> i32 {
2✔
31
        Self::count_valid_selections(nums)
2✔
32
    }
2✔
33
}
34

35
#[cfg(test)]
36
mod tests {
37
    #[test]
38
    fn test_solution() {
1✔
39
        super::super::tests::run::<super::Solution>();
1✔
40
    }
1✔
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc