Runtime Error in Longest Strictly Increasing Path Problem from Interview Contest

Hello ,
I gave one of the contest from Interview Contest.
More precisely Longest Strictly Increasing Path .
In my first attempt i got Runtime Error , Since Codedrills don’t provide constraints i thought it may be due to my static predefined dp matrix so i increased the size , but increasing size increased Runtime error.
Submission
Can you help me with my code, why and how remove RE!

2 Likes

Hi,
I’ve looked at your code and found the bugs. There are two mistakes (or assumptions) you make in your code. The break cases are:

  1. Empty grid, n = 0 and m = 0
  2. It is valid to assume that N*M <= 1e6 as that is the input size. But you make further assumption that N <= 2e3 and M <= 2e3 which need not be true.

The interview problems do not give the constraints unless its very needed as you are forced to write very optimized or generic code. This is also the reason the penalty is comparatively low (5 minutes).

I have made the minor fix here and it passes.

2 Likes

Thank you for response and solution , due to non constraints i totally forgot empty matrix , finally ACed

2 Likes