values and an integer gap.
Return the number of index pairs i < j such that |values[i] - values[j]| = gap.values=[4, 7, 1, 4, 10], gap=3 → 5
A difference of 3 appears for the value pairs (4, 7) twice, since there are two 4s, (4, 1) twice as well, and (7, 10). That is 5 pairs.
values=[2, 2, 2], gap=0 → 3
Any two elements are equal: pairs (0, 1), (0, 2), (1, 2), so 3.
values=[5, 9], gap=2 → 0
The only pair differs by 4, not 2.
values.length ≤ 200values[i] ≤ 10⁵gap ≤ 10⁵values=[4, 7, 1, 4, 10], gap=3
5
Run checks the first 3 tests in your browser. Submit checks all 108 tests on the server, hidden ones included.