Exchanging coins

why its giving TLE for one test case
link https://ide.codingblocks.com/s/208496

@dakshi

hello Dakshi,
check the constraints,
image

a) maximum value of n can be 10^9 in that case your solution will take around 10s which is more
b) u cannot make array of that big size so instead of using bottom up use top down dp + map to memoise