Back to problems

Items Purchase (For Java Backend Engineer)

Algorithm · PayPal · Medium

Problem You are given an array price of length n, where price[i] represents the original cost of the i‑th item in a shop. You are a frequent customer with exactly m discount coupons at your disposal. Each coupon can be applied to any item individually. If you apply x coupons to the i‑th item, its effective price becomes floor(price[i] / 2^x). Determine the smallest total amount you must spend to buy all n items, using at most m coupons across the entire purchase. Function…

Checking your access…