Google Phone Interview
Partition cards in sequences
We use cards numbered from 1-9.
valid sequence = three cards with consecutive numbers. E.g.234
invalid sequence = 256
The player has 12 cards, and wins if there exists a partition of them that forms 4 sequences.
Write a function that takes in a list of 12 numbers and decides whether or not it forms a winning hand.
//Can use a number only once
Input 1 : [ 1, 4, 3, 2, 5, 7, 8, 6, 9, 3, 2, 4]
//Sequences: 123, 456, 789, 234
o/p: True
input 2 [ 1, 4, 4, 2, 5, 7, 8, 6, 9, 3, 2, 4]
//Sequences: 123, 456, 789, (invalid)244
o/p: False