Can you please dry run this part first n=15 then we decrement n by coins[0] and n becomes 14 and this will continue till n==0 then the recursive function returns 1 and now please tell how the ans is calculated for each step

for( int i=0;i< m;i++){

if( n - coins[i] >= 0 ){  

    int subproblem = mincoins( coins,n-coins[i],m);  

    ans= min( ans,subproblem+1 ); 
    
} 

}

hello @anshulgurawalia
consider this->
ss

ss

similarly u can do it for n=15

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.