Finding the Sum of ‘Good’ Numbers with k-Distance Rule | O(n) Time |  O(1)  Space 
IntuitionThe problem requires identifying "good" numbers in the array based on their relative values at a given distance k. A number is considered "good" if it
# Intuition
The problem requires identifying "good" numbers in the array based on their relative values at a given distance k. A number is considered "good" if it is greater than both its k-th left and right neighbors (if they exist). The sum of all such "good" numbers is the result.

# Approach
Iterate through the array and check for each element if it satisfies the "good" number condition. Specifically, compare the element with its k-th left and right neighbors while handling boundary conditions. Maintain a running sum of valid numbers and return the final result.

# Complexity
- Time complexity:
 O(n)

- Space complexity:
 O(1) 

# Code
```javascript []
/**
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var sumOfGoodNumbers = function (nums, k) {
    let sum = 0;

    for (let i = 0; i < nums.length; i++) {
        let num1 = i - k;
        let num2 = i + k;

        if ((num1 < 0 || nums[i] > nums[num1]) && (num2 >= nums.length || nums[i] > nums[num2])) {
            sum += nums[i];
        }
    }

    return sum;
};

```
['JavaScript']