amounts. They want to cut the day into three non-empty contiguous stretches (morning, afternoon and evening) so that every stretch has the same sum.
Return True if such a split exists, and False otherwise. Elements cannot be reordered, and each element goes into exactly one stretch.amounts=[4, -1, 2, 5, 0, 3, 2] → True
[4, -1, 2] = 5, [5] = 5 and [0, 3, 2] = 5.
amounts=[1, 2, 3, 3] → True
The total is 9, so each piece must sum to 3: [1, 2], [3] and [3].
amounts=[2, 2, 2, -3, 3] → True
The total is 6, so the pieces must sum to 2 each, e.g. [2], [2], [2, -3, 3].
amounts=[4, -1, 2, 5, 0, 3, 2]
True
Run checks the first 3 tests in your browser. Submit checks all 80 tests on the server, hidden ones included.