Use a Boolean dynamic programming state for whether amount can be made exactly. Initialize and, for , computeAn empty disjunction is false. Any nonempty representation ends in some coin; removing it gives one of the displayed predecessor states, and adding it back proves the converse. Return . This takes time and space for positive integer denominations and nonnegative integer target , with unlimited coins of each type.
Articles by others on the same topic
There are currently no matching articles.