values and a number gap. You pick some of the elements (at least one). A pick is valid if no two chosen numbers differ by exactly gap in absolute value.
Return the number of valid picks. Picks are told apart by their sets of indices: if the array holds two equal numbers, taking one or the other counts as two different picks.values=[1, 4, 4, 7], gap=3 → 6
The valid picks are [1], [7], [1, 7], [4, 4] and [4], the last one in two ways since there are two 4s. That makes 6.
values=[2, 3, 9], gap=10 → 7
No two numbers differ by 10, so all 7 non-empty picks are valid.
values=[10], gap=5 → 1
values=[1, 4, 4, 7], gap=3
6
Run checks the first 3 tests in your browser. Submit checks all 69 tests on the server, hidden ones included.