Function to convert n into its digit vector and uses memo ( ) function to return the required count
static int CountNum ( int n ) { v . clear ( ) ; while ( n > 0 ) { v . add ( n % 10 ) ; n = n / 10 ; } Collections . reverse ( v ) ;