Partition all of nums into nonempty contiguous groups. Each group must be exactly one of these types:
- Two equal values.
- Three equal values.
- Three consecutive increasing values, with a difference of exactly
1between neighbors.
Return true if at least one such partition exists, and false otherwise. You may not reorder or omit elements.
Example 1:
Input: nums = [2,2]
Output: trueExplanation: Use the whole array as one group of two equal values.
Example 2:
Input: nums = [1,2,3,4]
Output: falseExplanation: A group of three consecutive values would leave one value ungrouped. Splitting into two groups of size two also fails because their values are unequal.
Example 3:
Input: nums = [7,7,7,2,3,4]
Output: trueExplanation: Split into [7,7,7] and [2,3,4]. The first group has three equal values, and the second has three consecutive increasing values.
Constraints:
2 <= nums.length <= 1000001 <= nums[i] <= 1000000