Optimal Game Strategy-2

Code is running fine on my editor but gives not output here
plz rectify it what is going wrong?

@aryamaan1011,

  • you are getting MLE (Memory Limit Exceeded) Error, ide does’nt allocate such a large array like dp[10000][10000] , so declare as dp[5000][5000] also in this question n is always less than 5000 (this is error in the question i will tell them to change it)
  • also since you have declared dp as global then there is no need for you to pass it in the function
  • also notice the base condition i have applied

corrected code :- https://ide.codingblocks.com/s/319316
In case of any doubt feel free to ask :slight_smile:
Mark your doubt as RESOLVED if you got the answer

@O17LPOLA020023 can u state one test case if we which we have overlapping subproblems and also is the naive recursive what is time complexity of naive recursive solutions ?