Traverse through every window
for ( int i = 0 ; i <= n - k ; i ++ ) { int [ ] newArr = new int [ k ] ; Array . Copy ( arr , i , newArr , 0 , k ) ; Console . WriteLine ( countWindowDistinct ( newArr , k ) ) ; } }