I’m solving this problem which is a basic LCS problem. I’ve solved some questions on this topic before but never got MLE (Memory Limit Issue) issue but this solution
is failing at some test cases. Can you please help me here?

1 Like

You have to optimize your solution codeforces questions are pretty difficult than any other platform!!

See the limits on N and then size of your dp[][]. So, MLE was error

1 Like

Nice Answer @sebastian :ok_hand:

Maybe you want to take a look at this: Marks Crisis!!! | Toph
The problem is reduced to Longest Increasing Subsequence, which can be solved in O(nlogn).