I have an array of certain length (say 8) 1,2,2,3,3,4,5,6
I wish to find number of subsequences of this array of length (say 4). This is 8 choose 4 (8C4
) = 70.
However, in the list of 70 subsequences above, I do not want to count sequences having duplicate elements e.g. 1223
1224
1334
2233
should be removed.
I have a solution for a single element being duplicated (i.e. array is 1,2,2,3,4,5,6,7
) Here the duplicates are 2C2*6C2
= 15 and answer required is 55
Is there a general formula/algorithm for moderately large array size and len (max hundred thousand). For the general case, the answer is calculated in modulo format.