Output of test case


#1

8 17 92 5 3 54 93 83 22 17 19 96 48 27 72 39 70 13 68 100 36 95 4 12 23 34 74 65 42 12 54 69 48 45 63 58 38 60 24 42 30 79 17 36 91 43 89 7 41 43 65 49 47 6 91 30 71 51 7 2 94 49 30 24 85 55 57 41 67 77 32 9 45 40 27 24 38 39 19 83 30 42 34 16 40 59 5 31 78 7 74 87 22 46 25 73 71 30 78 74 98 13 87 91 62 37 56 68 56 75 32 53 51 51 42 25 67 31 8 92 8 38 58 88 54 84 46 10 10 59 22 89 23 47 7 31 14 69

The expected output of this testcase is -1. But the longest path is 92->100. so the answer should be 2 right ?.


#2

i have the same issue and am unable to understand it !!!


#3

Exactly, needs a better explanation of the question.


#4

Please find the following explanation …hope it helps:
The longest path is not 92 -> 100 because in the matrix you are looking for a continuous path(without breaks) where if you are at index (i,j) you can only move to (i+1,j) if A[i+1][j] > A[i][j] or (i,j+1)…
Now 92 -> 100 is not the ans because when you want to reach 100 from 92 you are considering the values 92 -> 5 -> 3 -> 54 … -> 68 -> 100 which is not satisfying the condition mentioned ( if you are at index (i,j) you can only move to (i+1,j) if A[i+1][j] > A[i][j] or (i,j+1))


#5

It seems like a path is valid only if it ends in the bottom right cell. My answer which considers only paths ending in bottom right cell got accepted.


#7

The question is to reach the lowest row of the matrix. If we can reach the lowest row of the matrix, according to giving condition, then the path exists, otherwise not.
So, in this test-case, we can go from 92 -> 100 but 100 is not present in the last row and there is no other way to reach the last row so ans is -1.