FANG | OA | Consecutive integers of k groupsize subarray

input :- {1,3,2,4,2,3,6,7,8} groupSize :- 3
output = true

because the array can be devided in subarray of length groupsize containing consecutive integers by taking them only onceby taking them only once.
{1,2,3}
{2,3,4}
{6,7,8}

input - {1,2,3,4,5}
groupsize - 4;
output - false

because you cannot devide the subarray completely in subarray length of 4 containing consecutive integers.

constraints
1<=arr[i] <= 1000
1<=groupsize <= arr.length

Comments (0)