#3452

Sum of Good Numbers

pupil · 310 · lc easy +21 · 69.5% accepted · 79 likes · top 77%

Description

In an integer array nums, call nums[i] "good" if it strictly exceeds the values at positions i - k and i + k (when those positions exist). An element with neither neighbor at distance k is automatically considered good.

Return the total sum of all good elements.

Code

1
2
3