values and a threshold limit. Count the index triples i < j < k for which
values[i] + values[j] + values[k] < limit.
Triples are told apart by their indices: equal values at different positions form different triples.values=[3, -1, 4, 0], limit=4 → 2
The triples (3, -1, 0) with sum 2 and (-1, 4, 0) with sum 3 qualify. The other two sum to 6 and 7.
values=[2, 2, 2, 2], limit=6 → 0
Every triple sums to exactly 6, and the sum must be strictly less.
values=[5, 1], limit=100 → 0
Two numbers are not enough to form a triple.
values=[3, -1, 4, 0], limit=4
2
Run checks the first 3 tests in your browser. Submit checks all 94 tests on the server, hidden ones included.