On January 4, 2025, as we step into new beginnings, imagine you are helping a holiday organizer pack various gift bundles. Each gift bundle comes in a specific size denoted by an integer, and you have an unlimited number of each bundle available. Your task is to find all unique combinations of gift bundles that sum exactly to a given target value.
giftPacks
representing the sizes of gift bundles available.target
which is the desired total size.Note: The solution should use a backtracking approach to explore different combinations.
For giftPacks = [2, 3, 6, 7]
and target = 7
, one valid output is:
[
[7],
[2, 2, 3]
]
Remember: The order of numbers within the combination does not matter, and combinations should not be repeated.
Good luck and happy coding!