Ezvor

2979. Most Expensive Item That Can Not Be Bought

MediumMath Preparing judge… LeetCode
MathDynamic ProgrammingNumber Theory

Hints

Hint 1
Write out a few cases. It can be seen that all items greater than primeOne * primeTwo can always be bought.
Hint 2
If we can buy items with cost i, we can also buy items with price i + primeOne and i + primeTwo.
Hint 3
Use dynamic programming.
Hint 4
There is an O(1) solution: Use the Chicken McNugget Theorem.