Easy solution(Beats 100%)
IntuitionApproachComplexity
Time complexity:O(N)

Space complexity:O(1)
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

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

- Space complexity:O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class Solution {
public:
    int sumOfGoodNumbers(vector<int>& nums, int k) {
        int n=nums.size();
        int sum=0;
        for(int i=0;i<n;i++){
            if(i+k<n && i-k>=0){
                if((nums[i]>nums[i+k]) && (nums[i]>nums[i-k])){
                    sum += nums[i];
                }
            }else if(i+k>=n && i-k>=0){
                if((nums[i]>nums[i-k])){
                    sum += nums[i];
                }
            }else if(i+k<n && i-k<0){
                if(nums[i]>nums[i+k]){
                    sum += nums[i];
                }
            }else{
                sum += nums[i];
            }
        }
        return sum;
    }
};
```
['Array', 'C++']