Code Room
CodingMediumcod-g754
Subject KnapsackLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You are stocking a vending machine's change drawer. coins gives the available denominations and limits[i] gives how many coins of denomination coins[i] you have. Return the number of distinct coin values (sums) from 1 up to and including the total available that you can make exact change for using the coins on hand. Constraints: 1 <= n <= 50, 1 <= coins[i] <= 500, 1 <= limits[i] <= 100.

Implement
count_makeable_values(coins: list[int], limits: list[int]) → int
Examples
in[[1,5],[2,1]]out5
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.