Nice and elegant solution in java. Beats 100% RT and 100% memory.
```
class Solution {
    public int sumOfGoodNumbers(int[] nums, int k) {
        int sum = 0;
        for (int i = 0; i < nums.length; i++) {
            if ( (i + k <= nums.length - 1 && i - k >= 0) && (nums[i + k] < nums[i] && nums[i - k] < nums[i]) || (((i + k <= nums.length - 1 && i - k < 0) && (nums[i + k] < nums[i]))  || ((i + k > nums.length - 1 && i - k >= 0) && (nums[i - k] < nums[i]))) ) {
                sum += nums[i];
            }
        }
        return sum;
    }
}
```
['Array', 'Math', 'Java']