#Sum of Good Numbers || 100.00% || Easy to understand
IntuitionApproachComplexity
Time complexity:

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

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

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

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

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