Doubt in a Test Case

Check in this code works in test case: if n=9 and coins are 3 and 4 then your logic will return -2147483647 instead of 3, so put if(ans==INT_MAX) {return dp[n]=INT_MAX;}
after end of for loop to run this TC.

@touqeer11 please provide the ide link of the code about which you are talking

Jst give n=9 and coins as 3 and 4 and u will get what i am trying to say.

@touqeer11
as you can see in the code the ans variable is initialized with ‘INT_MAX’ and after the loops ( whether they execute or not) the ‘ans’ value is assigend to dp[n].

I hope it clears your doubt.
If still you have some doubt then please write the code and send me the ide link of it, then it will be better to discuss.