Input: N = 5, K = 4
Output: 1, 2, 3, 5, 4
Explanation: 4 subarrays which are a permutation of their own length are:
A[1] = {1}
A[1...2] = {1, 2}
A[1...3] = {1, 2, 3}
A[1...5] = {1, 2, 3, 5, 4}
Note that their exists no permutation of length 4 as a subarray.
Input: N = 7, K = 3
Output: {1, 2, 7, 4, 5, 6, 3}
Explanation: 3 subarrays which are a permutation of their own length are:
A[1] = {1}
A[1...2] = {1, 2}
A[1...7] = {1, 2, 7, 3, 4, 5, 6}
Their exists no permutations of lengths 3, 4, 5 and 6 as a subarray.
Below is the implementation of the above approach.