Easy and Readable C++ Code
IntuitionSince if any of nums[i - k] and nums[i + k] does not exist, still  nums[i] is considered good, so we can just initialize two integers as INT_MIN and if
# Intuition

Since if any of nums[i - k] and nums[i + k] does not exist, still  nums[i] is considered good, so we can just initialize two integers as INT_MIN and if nums[i - k] and nums[i + k] exists, we can update them.

# Complexity
- Time complexity: O(n)

- Space complexity: O(1)

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