fill memo array with min counts of elements that will constitute sum upto 100
for ( int i = 1 ; i < 100 ; i ++ ) { memo [ i ] = min ( memo [ i - 1 ] + 1 , memo [ i ] ) ; } for ( int i = 10 ; i < 100 ; i ++ ) { memo [ i ] = min ( memo [ i - 10 ] + 1 , memo [ i ] ) ; } for ( int i = 25 ; i < 100 ; i ++ ) { memo [ i ] = min ( memo [ i - 25 ] + 1 , memo [ i ] ) ; }