My code is working fine on the sample test case and on my custom test cases too but is giving me some "Run Error on submitting the code, please look into it and tell me where I am wrong.
Code : https://ide.codingblocks.com/s/245280
Run Error on HIdden Test Cases
hello @hargovind
a) value of n can upto 10^9 and we can not declare array of that big size( because it will consume too much memory). so use map and top down approach.
b) dont check whether i/n is divisible by 2/3/4 or not , simply take floor value.
for example -> 11/2=5.
@aman212yadav The top down approach worked, but can you tell me why the bottom up approach isn’t working, I tried to optimize it well and used map too, but it was giving TLE?
10^9 operations (when n=10^9 ) will take 10sec which will result in tle.
And Top Down approach is doing less than 10^9 operations?
yes, becuase in bottom up we will compute answer for all the states from 1 to 10^9.
but when we do top down then it will compute only those states that are required to answer for 10^9.
Okay, I get it! So this means that Top Down can be a more efficient approach than bottom up!
yeah . . . . . . . . .
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.