Hello sir/ma’am, I wrote the code for this problem, taking care of the base case. But it shows some error. That’s probably bcoz of the value of M i.e. 10^9. But if i reduce it then all the values of n will not be covered as given 1<=n<=10^9. Could you please tell how to deal with such big values.
Also when i try to run the code after keeping M=10^6 then the above error is not coming but none of the test case is being passed. Please tell me why is happening. Sharing my code:: https://ide.codingblocks.com/s/210887
Exchanging Coins DP
hello Priyanshi,
a) dont use array, use map to memoise
b)
dont check whether n is divisible by 2,3,4 or not. take floor value if any of them is not divisible
Okay, I used the map and made the change as you said. Still TLE is coming. https://ide.codingblocks.com/s/210887
@priyanshi.agarwal3405
use top down approach.
in bottom up approach ur code will do 10^9 operations in worst case which will cause tle.

remove these lines and take 0 value to distinguish between visited and non visited state.
Also In map 0 is default value so dont run any loop to intialise map with 0.
Okay sir…Thank you so much!!!
