← All problemsSign in

3452. Sum of Good Numbers

LeetCodeArrayOpen on judge ↗

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. Example 1: Input: nums = [1,3,2,1,5,4], k = 2 Output: 12 Explanation: The good numb

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start