Holiday Gift Sum

Backtracking Combinations Holiday Coding Challenge

Problem: Holiday Gift Sum

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.

Instructions:

  • You are given an array of integers giftPacks representing the sizes of gift bundles available.
  • You are also given an integer target which is the desired total size.
  • Each gift bundle can be used an unlimited number of times. The order of bundles in combinations does not matter.
  • Return all unique combinations of gift bundles that add up to the target.

Note: The solution should use a backtracking approach to explore different combinations.

Example:

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!