#3452
Sum of Good Numbers
easy · 69.5% accepted · 79 likes · top 77%
Description
Given an array of integers nums and an integer k, an element nums[i] is considered good if it is strictly greater than the elements at indices i - k and i + k (if those indices exist). If neither of these indices exists, nums[i] is still considered good.
Return the sum of all the good elements in the array.
Solution