Given a sequence of integers and an integer
N, output the number of contiguous subsequences that contain at least
N distinct integers. Each integer in the sequence is non-negative and will not be larger than the size of the sequence.
For example, with the sequence
N=2, there are 5 contiguous subsequences that contain at least 2 distinct integers:
1,2 1,2,2 2,2,3 2,3 1,2,2,3
The asymptotic time complexity must be linearithmic in the size of the input sequence. (The time complexity must be at most amortized
S is the size of the input sequence.)