weights lists the weight of each one. The row is cut at a single spot between two neighbouring crates, leaving at least one crate on each side.
Return the number of spots where the cut makes the difference between the total weight on the left and on the right an even number.weights=[4, 7, 1, 2] → 3
The cuts give 4 | 10 (difference −6), 11 | 3 (8) and 12 | 2 (10): all three are even.
weights=[3, 2, 2] → 0
The cuts give 3 | 4 (−1) and 5 | 2 (3): both differences are odd, so the answer is 0.
weights=[4, 7, 1, 2]
3
Run checks the first 3 tests in your browser. Submit checks all 92 tests on the server, hidden ones included.