Python Easy Soltion || Beats 100% 💯|| O(n) || Easy Approach || 0 ms 
IntuitionThe problem requires finding numbers in an array that are strictly greater than their k-th left and right neighbors (if those indices exist). The idea
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
The problem requires finding numbers in an array that are strictly greater than their k-th left and right neighbors (if those indices exist). The idea is to iterate through the array and check each element’s validity based on its available neighbors.

---


# Approach
<!-- Describe your approach to solving the problem. -->
1. Initialize an empty list res to store the "good numbers."
2. Check the conditions for a "good number":
3. If the index i - k exists (i - k >= 0), check if nums[i]>nums[i - k].
4. If the index i + k exists (i + k < n), check if nums[i] > nums[i + k].
5. If either index does not exist, the condition is automatically considered valid.
6. If both conditions hold, add nums[i] to res.
7. Return the sum of all elements in res as the final result.

---


# 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)$$ -->
    0(1)

# Code
```python3 []
class Solution:
    def sumOfGoodNumbers(self, nums: List[int], k: int) -> int:
        res=[]
        for i in range(len(nums)):
            if (i-k<0 or nums[i]>nums[i-k]) and (i+k>=len(nums) or nums[i]>nums[i+k]):
                res.append(nums[i])
        return sum(res)
```
![123.png](https://assets.leetcode.com/users/images/19a2a048-20ad-4ab6-9ecf-f46bf40642de_1739809992.6702528.png)
```


['Python3']