✅Easy to Understand | Full Explanation | C++ Code
IntuitionOut of bounds and in range all the combinatation consideredApproachWe wanted:
if i-kand i+k is in boundnums[i - k] < num && nums[i + k] < num is good n
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

Out of bounds and in range all the combinatation considered

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

We wanted: 
if `i-k`and `i+k` is in bound

`nums[i - k] < num` && `nums[i + k] < num` is good number

Test cases considers:

1. If both the indexs are out of bounds
2. If `i-k` is out of bounds
3. If `i+k` is out of bounds
4. If none of them is out of bounds

In these cases it is good number so we add the `nums[i]` to the `ans`




# Code
```cpp []
class Solution {
public:
    int sumOfGoodNumbers(vector<int>& nums, int k) {
        int n = nums.size();

        int ans = 0;

       for (int i = 0; i < n; i++) {
            int num = nums[i];

            if (i - k < 0 && i + k >= n) {
                ans += num;
            } 
 
            else if (i - k < 0 && i + k < n && nums[i + k] < num) {
                ans += num;
            } 
   
            else if (i + k >= n && i - k >= 0 && nums[i - k] < num) {
                ans += num;
                
            } 
          
            else if (i - k >= 0 && i + k < n && nums[i - k] < num && nums[i + k] < num) {
                ans += num;
            }
        }

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