I am getting wrong ans for all test cases. Can you please tell me if my understanding of question is correct ?
Exchanging Coins approach
there can be two ways , either observe the pattern of the answers or memoise the answer using dp.
I want to know if my understanding of the question is correct or not. ?
That we have just two options. Either we can exchange the coin with n/2,n/3 and n/4 or we can get gold.
for example we have coin of 24.
so we can exchange it with 12+8+6 or we can get gold for 24. If we choose option 1, then we can only exchange 12 as it is divisible by 2,3,4 so we will get 13 so output should be 27. Or is it correct or the question is different ?
you have to take the maximum value of two things here;
1)answer when you break it in coings of n/2,n/3,n/4
2)or simply sell it for a gold coin for n;
getting TLE for one test case.
I thing it is heapoverflow
stackoverflow! watch my code , i have memoised answer for n less than 1e6.
Thank you so much It worked…