You are given two integers C,KC,K and an array of NN integers a1,a2,...,aNa1,a2,...,aN. It is guaranteed that the value of aiai is between 11 to CC.
We define that a continuous subsequence al,al+1,...,ar(l≤r)al,al+1,...,ar(l≤r) of array a is a good subarray if and only if the following condition is met:
It implies that if a number appears in the subarray, it will appear no less than KK times.
You should find the longest good subarray and output its length. Or you should print 00 if you cannot find any.
We define that a continuous subsequence al,al+1,...,ar(l≤r)al,al+1,...,ar(l≤r) of array a is a good subarray if and only if the following condition is met:
∀x∈[1,C],∑i=lr[ai=x]=0or∑i=lr[ai=x]≥K∀x∈[1,C],∑i=lr[ai=x]=0or∑i=lr[ai=x]≥K
It implies that if a number appears in the subarray, it will appear no less than KK times.
You should find the longest good subarray and output its length. Or you should print 00 if you cannot find any.