Matrix Seach(Staircase Problem)

What mistake I am doing ??

In staircase search, you take the top right element of the matrix as the starting point (as this is a point in matrix from where if you move downwards, the number increases and if you move leftwards, the number decreases).
But in the code you have taken arr[0][0] as the starting point. This is not the correct starting point for staircase search as on both the directions (rightwards and downwards) ,the elements increases.
Please watch the lecture video of Staircase search for more clarity.

1 Like