Rust | 0ms | 1-liner
CodeCodeNot valid on leetcode as of 2025-03-12
# Code
```rust []
impl Solution {
    pub fn sum_of_good_numbers(nums: Vec<i32>, k: i32) -> i32 {
        nums.iter()
            .enumerate()
            .filter_map(|(i, &num)| {
                (nums.get(i + k as usize).map_or(true, |&v| num > v)
                    && i.checked_sub(k as usize).map_or(true, |p| num > nums[p]))
                .then_some(num)
            })
            .sum()
    }
}
```
# Code
Not valid on leetcode as of 2025-03-12
```rust [Rust: using is_none_or]
impl Solution {
    pub fn sum_of_good_numbers(nums: Vec<i32>, k: i32) -> i32 {
        nums.iter()
            .enumerate()
            .filter_map(|(i, &num)| {
                (nums.get(i + k as usize).is_none_or(|&v| num > v)
                    && i.checked_sub(k as usize).is_none_or(|p| num > nums[p]))
                .then_some(num)
            })
            .sum()
    }
}
```
['Rust']