Getting Time Limit Exceeded

Hello

I am doing this question from HackerEarth…

What i have done is for ecah test cases…
First i have sorted the coins value in descending order and then done the three steps
1.Picked the coin and didn’t move forward.
2.Picked the coin and move to next coin.
3.Didn’t picked coin and move to the next.
Thus i have calculated the minimum number of coin.
But i am getting tle in submission although i have done memoization.
This is my suggestion
Please look into it
https://www.hackerearth.com/submission/52059367/
Thanks

Hey @ashishnnnnn
Logic is correct
Solve it using Bottom UP instead, constraint may be tight so top down recursion will not work.

Hey @ashishnnnnn
did u try ?

No… Not yet…
Actually i have never written code in bottom up approch.
I am trying to learn this with smaller problem…

Oh alright
For any DP PROBLEM
Think like this Recursive ->TopDown->Bottum UP