Search
⌘K

Leetcode 2473. Minimum Cost to Buy Apples

Given costs for apple packs (typically of sizes that double: 1, 2, 4, …), find the minimum cost to buy at least a target number of apples by choosing any combination of packs. This is an unbounded knapsack / DP problem where you optimize pack prices (handle missing/cheaper larger packs) and often use binary decomposition or greedy on powers-of-two packs to form the target.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.