One of the testcase gets TLE error and the other one passes.
Sir, getting TLE in current problem
@pangatt4 there’s no need for memoization (so don’t use maps)
Also return 1+max(calculate(v, dp, chk, st, i-1), calculate(v, dp, chk, i, en)); as soon as lft==rgt (no need to check for further indices)
1 Like
this works fine now
1 Like
Okay, so it is plain recursion, and no overlapping subproblems.