Stores frequency of elements separated by distance K
Dictionary < int , int > freq = new Dictionary < int , int > ( ) ; for ( int j = i ; j < N ; j += K ) { if ( freq . ContainsKey ( arr [ j ] ) ) freq [ arr [ j ] ] ++ ; else freq . Add ( arr [ j ] , 1 ) ; }