← 返回 google 的题目列表Split Array into Consecutive Subsequences of Length Five
类型:online_judge
google
Given an array of integers, determine if the array can be split into consecutive subsequences of length 5. Please write a function to solve this problem. The function should return a boolean indicating if the condition is satisfied.
Input: An array of integers.
Output: A boolean indicating if the array can be split into groups of 5 consecutive numbers.
Test cases:
Input: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] Output: True
Input: [1, 2, 3, 4, 6, 7, 8, 9, 10] Output: False
Input: [1, 1, 2, 2, 3, 3, 4, 5, 6] Output: False
Constraints: The array size is between 1 and 10^5, the integers in the array range between 0 and 10^6.
Example
Input
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]