values and an integer gap. Call values[i] a standout if it is strictly greater than values[i - gap] and strictly greater than values[i + gap], comparing only against those positions that actually exist in the array. If neither position exists, the element is a standout as well.
Return the sum of all standout elements.values=[4, 9, 2, 7, 3], gap=2 → 16
Index 0 (4) is compared only with index 2 (2) and wins. Index 1 (9) beats index 3 (7). Index 2 (2) loses to 4. Index 3 (7) loses to 9. Index 4 (3) beats 2. Total 4 + 9 + 3 = 16.
values=[5, 5], gap=1 → 0
A tie does not count: neither 5 is strictly greater than the other, so the sum is 0.
values=[4, 9, 2, 7, 3], gap=2
16
Run checks the first 3 tests in your browser. Submit checks all 106 tests on the server, hidden ones included.