link which digits must be equal
Vector < Integer > [ ] connectchars = new Vector [ k ] ; for ( int i = 0 ; i < k ; i ++ ) connectchars [ i ] = new Vector < Integer > ( ) ; for ( int i = 0 ; i < n ; i ++ ) arr [ i ] = i % k ;