I used top down DP for solving this problem and yet there is a TLE error in submission. Please help.
https://practice.geeksforgeeks.org/problems/count-ways-to-reach-the-nth-stair-1587115620/1
I used top down DP for solving this problem and yet there is a TLE error in submission. Please help.
https://practice.geeksforgeeks.org/problems/count-ways-to-reach-the-nth-stair-1587115620/1
I made the changes, still it is not being submitted. It’s showing wrong answer.
check now->
^ is xor operator so dont use it.
u r asked to take mod with 1000000007
I tried that too. Still showing wrong answer. The answer my code is generating here is somehow being negetive (atleast that is what their compiler says). I tried to stop the overrflow using long long int instead of int. Still, does not work.
bro check my last response , i already shared the corrected code.
Your solution is being accepted and submitted. Please help me understand that why are we doing modulus twice? The final answer returned had to be the modulus. Why are we storing the modulus 1000000007 in the dp array?
are u aware of modulo arithmetic properties?
Yes, gives the remainder?
no , i m talking about modulo arithmetic properties.
read about it , and ping me back once done
Is it because of the addition property (a+b)%M= (a%M + b%M)%M ?
yeah correct . . . . . . .
Thanks a lot for helping me understand. This concept is new to me, I’ll think more about it. I’ll ask any follow up doubts on this if it arises. Thanks again.
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.