Python Solution-Beats 100%
Complexity
Time complexity:

Space complexity:
Code

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
    O(n)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
    O(1)
# Code
```python3 []
class Solution:
    def sumOfGoodNumbers(self, nums: List[int], k: int) -> int:
        total = 0
        n = len(nums)

        for i in range(n):
            left = nums[i - k] if i - k >= 0 else float('-inf')
            right = nums[i + k] if i + k < n else float('-inf')

            if nums[i] > left and nums[i] > right:
                total += nums[i]

        return total
```
['Python3']