In the holiday spirit, imagine you're creating unique gift baskets from a store of available gift items. Each gift has a positive integer price and you have a total budget. Your task is to determine the number of distinct ways you can choose gifts (using an unlimited supply of each gift) such that their total price exactly matches your budget. The order in which the gifts are chosen does not matter.
Given an array of positive integers prices
and an integer total
, implement a function giftBasketCount(prices, total)
that returns the number of distinct combinations of gifts that add up to total
.
For prices = [2, 3, 5]
and total = 7
, the output should be 2
.
Explanation:
If no combination of gifts can sum up to total
, return 0
.
Happy coding and enjoy the holiday season!