Simple Loop || 100% beast || 1ms fast solution || O(n) Complexity
IntuitionSimple follow the conditions and you will get the logic to approach the problem.ApproachChecks for the conditions and just a simple iteration over the
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
Simple follow the conditions and you will get the logic to approach the problem.

# Approach
<!-- Describe your approach to solving the problem. -->
Checks for the conditions and just a simple iteration over the full array add the sum in a variable and simply return that.

# Complexity
- Time complexity:
1. O(n)

- Space complexity:
- O(1)
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
# Code
```java []
class Solution {
    public int sumOfGoodNumbers(int[] nums, int k) {
        int sum=0;
        int n=nums.length;
        for(int i=0; i<n; i++){
            //  checks if the indices exist or not if exist whether it is greater than the nums[i] or not
            boolean left = (i - k >= 0 && nums[i] <= nums[i - k]);
            boolean right = (i + k < n && nums[i] <= nums[i + k]);
            //  if both the cases are got to be true only then add it to the sum of number
            if(!left && !right)
                sum+=nums[i];
        }
        return sum;
    }
}
```
['Java']