This is passing one tc but showing Run time error in other
Then I referred the hint and it is the same but the constraints have n<=17000 but we can’t make a 2D matrix of 17000x17000. What is wrong here?
Run time error in 1st TC
the constraints are high. why wouldn’t I use memoization. even if I use it, it shouldn’t case a problem. anyway without using memoization it gives TLE. If you can point out what is wrong in my solution, it would help. Thanks
@akh.chakraborty11,
Memoization does not depend on constraints, it depends, on whether there are overlapping subproblems or not. Can you find overlapping subproblems in this problem…??
Yes there are overlapping sub problems. I did it on my notebook as well.
@akh.chakraborty11,
Please share the example you think has overlapping subproblems, because if you think logically, you make two mutually exclusive recursive calls from any state, so obviously, there can’t be any overlapping…??
Then how should I proceed? Binary search?
I solved it using binary search. Thanks
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.