This is a coin change problem using DP.