values. Cut it into one or more contiguous pieces so that every piece is "good". A piece is good if it is:
- exactly two equal numbers, such as [6, 6];
- exactly three equal numbers, such as [1, 1, 1];
- exactly three numbers where each is 1 more than the previous one, such as [8, 9, 10] (but not [8, 10, 12] or [10, 9, 8]).
Return true if such a cut exists, and false otherwise.values=[7, 7, 3, 4, 5] → True
Cut into [7, 7] and [3, 4, 5]: a pair of equal numbers and three consecutive ones.
values=[2, 2, 2, 2, 2] → True
[2, 2] and [2, 2, 2] works.
values=[5, 6, 7, 9] → False
The final 9 cannot belong to any good piece: no pair or triple around it fits.
values=[7, 7, 3, 4, 5]
True
Run checks the first 3 tests in your browser. Submit checks all 137 tests on the server, hidden ones included.