Understanding staircase search algorithm


The strategy from the earlier example could be used to create an algorithm. To explain this algorithm, we will use a 2D matrix sorted by row and column in ascending order and search for a target number. For the algorithm to work, the input matrix should meet the condition below.

  • The matrix should be sorted in rows and columns, meaning each row and each column is sorted in ascending order.
Loading Image

Valid input for staircase search

Liking the course? Check our discounted plans to continue learning.