Doubt in 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;}
to run this TC.