
Consider ‘N’ = 6, 'CARDS' = [1, 3, 2, 2, 4, 3] and ‘GROUPSIZE’ = 2.
Then, the first and third cards with numbers 1 and 2 can be in one group, the second and fourth cards with numbers 3 and 2 can be in one group and the fifth and the sixth cards with numbers 4 and 3 can be in one group.
Hence we return true.
The first line contains two integers ‘N’ and 'GROUPSIZE', representing the number of cards and the size of each group.
The second line will contains ‘N’ space-separated integers representing array ‘CARDS’.
Print 'true' if cards can be divided into groups. Else print 'false'.
You don’t need to print anything; It has already been handled. Just implement the given function.
Approach