implementation of coin problem with greedy and dynamic approach