Search an element in a 2D array (matrix) sorted row-wise and col-wise

Linear search is O(N2) for an N by N matrix but doing that would mean that we are not using the
sorted property of the matrix. We cannot apply binary search considering the matrix to be one array of length
NxN because sorting is only per row and per column i.e. the matrix could have the following form: