long long num(long long p)
{
if(p<0)
return 0;
if(p==0)
return 1;
if(t[p]!=0)
return t[p];
t[p]=num(p-1)+num(p-2)+num(p-5)+num(p-10)+num(p-20)+num(p-50)+num(p-100);
return t[p];
}
I use this method num
to count number of possible ways of coin change problem.The problem is this approach counts 1,1,2
and 1,2,1
as different which should be taken as 1 .How to do that?
Cant find any good solution anywhere.