Ugly numbers dp

my code is showing wrong answer plz check the code and find the mistake and correct it

problem : https://online.codingblocks.com/app/player/39658/content/77394/5286/code-challenge

code : https://ide.codingblocks.com/s/210092

plz reply ASAP

@sengarankit98 Your code output for first 20 numbers is:- 0 1 2 3 4 5 6 8 9 10 12 14 15 16 18 20 21 22 24 25 26
in which you can see 21, 22, 26 are not correct, actually this approach is wrong and will not work.

The correct way will be building the ugly numbes from start.
for eg:- 1, 2, 3 5 are starting ugly numbers. So all the next ugly numbers will be multiples of 2, 3 and 5 as it is said in the question.
Here the next ugly number will be minimum(22, 32, 52) so it will be 4
then next will be minimum(2
3, 32, 52) so you can take any, lets take, 32.
next will be (2
3, 33, 52) and so on…

So you just have to keep track of multiple for 2, 3 and 5 and decide minimum.

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.