Function to convert n into its digit vector and uses memo ( ) function to return the required count
int CountNum ( int n ) { v . clear ( ) ; while ( n ) { v . push_back ( n % 10 ) ; n = n / 10 ; } reverse ( v . begin ( ) , v . end ( ) ) ;