Google | Phone screen | Split Array into Consecutive Subsequences
Anonymous User
1158
Jun 14, 2019
Jul 13, 2019

https://leetcode.com/problems/split-array-into-consecutive-subsequences
There is a cards array that contains n cards. Each card id is from 1 to 13. Consecutive (in terms of card ID, not array index) X cards make X-straight. For example 2-3-4 makes 3-straight. X should be at least 3. Is it possible to put all cards in straights? Each card will belong to one straight. Array is not necessarily sorted. Each card can appear multiple times.

Example 1:

Input: cards = [2, 3, 4, 1, 2, 3, 4]
Output: true
Explanation: 2-3-4 and 1-2-3-4. (3-straight and 4-straight).

Example 2:

Input: cards = [1, 2, 1, 2, 3]
Output: false
Explanation: 1-2-3 is 3-straight, but 1-2 is 2-straight. We need at least 3-straight.
Comments (6)