values. Look at every window of three consecutive elements. A window is good if the sum of its two outer elements is exactly half of the middle one.
Return the number of good windows.values=[3, 2, 10, 3, 0] → 1
In [2, 10, 3] the ends add up to 5, exactly half of 10. In [10, 3, 0] the ends add up to 10 while half of 3 is 1.5. The answer is 1.
values=[-1, -4, -1] → 1
-1 + (-1) = -2, which is half of -4.
values=[4, 4, 4] → 0
The ends add up to 8, while half of the middle is 2.
values=[3, 2, 10, 3, 0]
1
Run checks the first 3 tests in your browser. Submit checks all 123 tests on the server, hidden ones included.