Trains the technique from
LeetCode 3946Maximum Number of Items From Sale IThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A sale lists its lines as items, where items[i] is [factor, price].
Line i is sold only as a whole bundle: taking it means buying exactly factor units at price each, so the bundle costs factor times price and yields factor units. A line may be taken once or left alone.
With budget to spend, return the greatest number of units that can be bought.
Example 1
The four bundles cost 12, 14, 18 and 15 and yield 3, 7, 2 and 5 units. Taking the second and fourth costs 29 and yields 12 units, and no choice inside 40 does better.
Example 2
One bundle costs 10 and yields 10 units, the other costs 10 and yields 1, so the budget goes on the first.
Example 3
The only bundle costs 2, which is over budget, so nothing can be bought.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def maximum_sale_items(items: list[list[int]], budget: int) -> int:public int maximumSaleItems(int[][] items, int budget)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.