values, a number key that occurs in the array, and a radius.
Position i is near the key if there is some position j with values[j] == key and |i - j| ≤ radius.
Return every position near the key (0-based) in increasing order.values=[6, 2, 8, 2, 5, 1, 7], key=2, radius=1 → [0, 1, 2, 3, 4]
The value 2 sits at positions 1 and 3. Within 1 of them are positions 0, 1, 2, 3, 4. Positions 5 and 6 are too far.
values=[4, 4, 9, 4], key=9, radius=0 → [2]
With radius 0 only the position holding 9 itself qualifies.
values=[1, 3, 3], key=1, radius=3 → [0, 1, 2]
values.length ≤ 1000values[i] ≤ 1000key occurs in valuesradius ≤ values.lengthvalues=[6, 2, 8, 2, 5, 1, 7], key=2, radius=1
[0, 1, 2, 3, 4]
Run checks the first 3 tests in your browser. Submit checks all 103 tests on the server, hidden ones included.