I have a sequence a with length N created by removing some elements (possibly zero) from a permutation of numbers (1,2,…,N). When an element is removed, the length of the sequence doesn't change, but there is an empty spot left where the removed element was. You also have an integer K.
Let's call a permutation p1,p2,…,pN good if:
it is possible replace empty spots in a by numbers in such a way that we obtain the permutation p the number of positions i ( 1 < i ≤ N ) such that pi > pi−1 is equal to K My task is to find the number of good permutations.
Eg n=3 elements k=1 given array (2 ,* ,*) answer=2 explanation:two possible ways (2,3,1) ans (2,1,3)