Given a set of tiles (represented by numbers from 0 - 9), a valid configuration of tiles for success at this game happens only when the entire set can be divided such that:
- There is at least 1 pair [e.g. - 9,9]
- There can be any number of triples. [e.g. - 1,1,1] . No. of triples can be 0 as well.
- There can be any increasing triple [e.g. - 1,2,3] . No. of increasing triples can be 0 as well.
Eg:-
-
Set of tiles : 11123
Output : True , as above set of tiles can be 11 (pair) and 123 (increasing triple) -
Set of tiles : 11111
Output: True, as above set of tiles can be 11(pair) and 111(triple) -
Set of tiles : 1123
Output: False , as the above set can be divided into a pair (11), but (23) are extra.
I tried branching on the above set, s.t. at each step we either pick a pair or not pick a pair, but my solution was not correct.
Can anyone please help what should be the correct approach for this problem?
Comments (29)


