Trains the technique from
LeetCode 1833Maximum Ice Cream BarsThis 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 collector arrives at a flea market holding budget tokens, the only currency the stalls accept.
One stall has a crate of second-hand records laid out. Record i is tagged at prices[i] tokens. The collector may take away any group of records, in any combination, as long as the tags of the records taken add up to no more than budget. Records are sold whole: there is no haggling, no swapping and no part payment, and each record in the crate can be taken at most once even when two of them carry the same tag.
Return the largest number of records the collector can walk away with.
Example 1
Taking the two records tagged 4 and the one tagged 9 uses 4 + 4 + 9 = 17 tokens, which is the whole budget, and hands over three records.
Example 2
The three records tagged 3 cost 9 tokens together, leaving 2 tokens unspent and three records in hand.
Example 3
Both tags are above the whole budget, so nothing can be taken and the collector leaves empty-handed.
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 max_records(prices: list[int], budget: int) -> int:public int maxRecords(int[] prices, int budget)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.