Logic of staircase search

i cannot think of the logic of this search algo. can u tell me how to approach this algo ?

@Raghavsingla522 You can follow the following steps:

  1. Let the given element be x, create two variable i = 0, j = n-1 as index of row and column
  2. Run a loop until i < n && j>=0
  3. Check if the current element is greater than x then decrease the count of j. Exclude the current column.
  4. Check if the current element is less than x then increase the count of i. Exclude the current row.
  5. If the element is equal then print the position and end.