An online shop prints shipping labels using stamp values from stamps, and it has an unlimited supply of each value. A label is valid only if the stamps on it add up to exactly postage.
Write canPayPostage(stamps, postage) that returns true if some combination of stamps adds up to exactly postage, and false otherwise. A postage of 0 needs no stamps, so it is true.
Input: stamps = [4,7], postage = 15 Output: true
4 + 4 + 7 = 15.
Input: stamps = [4,7], postage = 13 Output: false
Taking away 7 leaves 6 and taking away 4s leaves 9, 5, or 1, and none of those can be made.
1 <= stamps.length <= 201 <= stamps[i] <= 10000 <= postage <= 10000Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #523 Pay Postage With Unlimited Stamps. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.