int coinchange_bottom(int n, int t, int coins[]){
int dp[100]={0};
for(int i=1; i<=n; i++){
int ans=INT_MAX;
for(int j=0; j<t; j++){
if(n-coins[j]>=0){
ans=min(dp[n-coins[j]]+1,ans);
dp[i]=ans;
}
}
}
return dp[n];
}
I am getting answer as 2 for 15 and 9 whereas the correct answer for both should be 3. I cannot find the mistake in the code please help.
coins[]={1,7,10};
t=3;