Divide positive integers in sets of k consecutive numbers

Recursion

Given an array of positive integers nums and a positive integer k, check whether it is possible to divide nums into sets of k consecutive numbers.

Write a recursive function to solve this problem. Return true if it is possible. Otherwise, return false. The input has 2 lines. The first line is the array of positive integers nums. The second line is the positive integer k.

Important Info:

Example 1:

Input:
1 2 3 3 4 5 5 6
4

Output:
false

Explanation: Array can be divided into [1,2,3,4] and [3,5,5,6]. However, [3,5,5,6] is not a set of 4 consecutive numbers.

Example 2:

Input:
1 2 2 3
2

Output:
true

Explanation: Array can be divided into [1,2] and [2,3].

Example 3:

Input:
1 2 3 4 5
2

Output:
false

Explanation: Array cannot be divided into sets of size 2.