Hand of Straights

Practice this coding question on Coding Gurukul.

Problem statement

A workshop has numbered badges and wants to pack every badge into kits of exactly k badges. The labels within each kit must be consecutive integers, with no repeated label in a kit. Repeated labels may appear in different kits. Determine whether all badges can be packed.

Input format

First line: n k. Second line: n badge labels.

Output format

Print true or false in lowercase.

Constraints

1 <= k <= n <= 10000; 0 <= label <= 1000000000.

Sample input

6 3
4 5 6 5 6 7

Sample output

true

Sign in to run or submit a solution in C++, Java or Python.