values and a positive integer step. A triple of indices i < j < k is good if values[j] - values[i] == step and values[k] - values[j] == step.
Return the number of good triples.values=[2, 5, 8, 9, 11, 14], step=3 → 3
The triples 2, 5, 8 / 5, 8, 11 / 8, 11, 14 all work.
values=[0, 1, 3, 4, 7], step=2 → 0
Each step must be 2: 1 → 3 exists but 5 does not, and 0 → 2 fails since there is no 2. The answer is 0.
values=[10, 20, 30, 40], step=10 → 2
values is strictly increasingvalues=[2, 5, 8, 9, 11, 14], step=3
3
Run checks the first 3 tests in your browser. Submit checks all 107 tests on the server, hidden ones included.