←ENG-DSA-071Promotion Bundling (Combination Sum)
00:00
🐍 Python Idle
Mode:Web

Promotion Bundling (Combination Sum)

CompaniesAmazon, Walmart
Est. Time~45 min
LevelMid
BacktrackingArrays
🚨 P0 Incident
AmazonWalmart

E-commerce checkout systems generate targeted "bundle" discounts. To trigger a "$50 off your cart" coupon, the system must calculate if combinations of items from a promotional catalog sum exactly to the target threshold. Customers can buy the same promotional item multiple times.

πŸ“₯ Assigned to:You β€” Mid Engineer
Your Task

Given an array of distinct integers `prices` and a target integer `target`, return a list of all unique combinations of prices where the chosen numbers sum to `target`. You may choose the same price an unlimited number of times.

⏱ Time: O(N^(T/M)) (T=target, M=min_val)πŸ’Ύ Space: O(T/M) stack space
Example 1
Input:Β Β prices=[2,3,6,7], target=7
Output:Β [[2,2,3], [7]]
Example 2
Input:Β Β prices=[2,3,5], target=8
Output:Β [[2,2,2,2], [2,3,3], [3,5]]
πŸ”’ +3 hidden test cases β€” revealed on Submit
Hints
Loading editor…
Test Output
β–Ά Run Code to test against examples Β· Submit to judge all 5 test cases
EngPrep β€” Real Engineering. Real Interviews.