This same question is on leetcode but showing error

i am having trouble in leetcode same question

Hey @anmolaggarwal.432 share question link and your solution too which you are submitting.

Won’t be able to see your submission. You have to share it separately. Also share the link of the problem, share that separately.

And also question link which you are mentioning. Share it’s link too.

It si in the video of alogoritm stl video 5

Bro leetcode question link . I got your solution but not leetcode problem statement for which you have solved. Share me that leetcode problem link.


So this problem won’t be solve like this, it’s a problem of 0-1 knapsack. Let me give you an example where your code will fail.
Suppose your number n is 11 and types of coin you have is: 1 5 6 9
According to logic of your code, you will get an output of: 9 ,1 ,1 ,
That is 3 coins. But minimum coin required to make a sum of 11 will be 2(coin 6 + coin 5)
So you have to solve this using 0-1 knapsack approach.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.