values. Count the index quadruples a < b < c < d such that
values[a] + values[b] + values[c] == values[d].
In other words, three elements add up to some element that sits to the right of all three. Different sets of indices count as different quadruples even when their values are the same.values=[2, 4, 1, 7] → 1
2 + 4 + 1 = 7, so the index quadruple (0, 1, 2, 3) is the only one that works.
values=[1, 2, 1, 4, 4] → 2
1 + 2 + 1 = 4, and either 4 can serve as the last element: (0, 1, 2, 3) and (0, 1, 2, 4). No other triple sums to 4.
values=[9, 1, 1, 1] → 0
The total must come after the three addends, and 9 + 1 + 1 is not 1.
values=[2, 4, 1, 7]
1
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.