Simple Approach. Use Paris C++ || O(n)
Use pairs to store the values of nums[i-k] and nums[i+k]. Next compare these and add nums[i] if condition satisfies ;).Complexity
Time complexity:O(n)

Space co
Use pairs to store the values of nums[i-k] and nums[i+k]. Next compare these and add nums[i] if condition satisfies ;).

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

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

![image.png](https://assets.leetcode.com/users/images/4945f655-72c5-47e1-a676-74021708b13c_1739682678.880919.png)

# Code
```cpp []
class Solution {
public:
    int sumOfGoodNumbers(vector<int>& nums, int k) {
        // we can solve problem using pairs !
        // consider a vector of pair !
        int n = nums.size();
        vector<pair<int, int>> v;
        
        // compare and store the results in the pair !
        for(int i = 0; i < n; i++){
            int A = (i >= k) ? nums[i-k] : -1;
            int B = (i + k < n) ? nums[i+k] : -1;

            v.push_back(make_pair(A,B));
        }

        int result = 0;
        for(int i = 0; i < n; i++){
            if(nums[i] > v[i].first && nums[i] > v[i].second){
                result += nums[i];
            }
        }

        return result;
    }
};
```
['C++']