There is a same ques optimal game strategy like this just before.Whats different in both ques?
Whats difference between previous one?
Hey @pranjalarora98
Main difference between both the question is that since Optimal-1 has array size of max 30 so in that question simple recursion without dp will give you All Test Case passed.
but since Optimal 2 has bigger array size using recursion without memoization will not be efficient so you need to use dp in second one while you don’t need dp in first one.
and if you are submitting same code from the first one atleast change the array size as per constraints of current problem.using dp array of size 50 will give you wrong answer for sure in second optimal problem.
In first i was using dp solution.And in second 8 cases passed and 3 gave error
So i made a global dp array and it worked.Is it fine to use dp everywhere and no recursion? Coz i am not comfortable with recursion
Yes its fine
But sometimes Recursive solutions are easier than Iterative approaches
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.