Simple Logic
Code
# Code
```python3 []
class Solution:
    def sumOfGoodNumbers(self, nums: List[int], k: int) -> int:
        # Greedy
        # Time Complexity: O(n)
        # Space Complexity: O(1)
        n = len(nums)
        _sum = 0
        for i in range(n):
            if (i - k >= 0 and nums[i] <= nums[i-k]) or (i + k < n and nums[i] <= nums[i+k]):
                continue
            _sum += nums[i]
        return _sum
```
['Python3']