title: Completely Sorted matrix
body: <p>This question was asked to me in one of my job interviews - </p>
  
  <p>M is a 2d n-by-n matrix in which every row and every column is sorted, and all the matrix elements are different. I need an O(n) algorithm - Given indices i, j, i0, j0 as input, compute the number of elements of M smaller than M[i, j] and larger than M[i0, j0]. I tried various approaches for this, but couldn't figure out. Help will be greatly appreciated. The next part was to find out the median of M in O(nlogn) expected time.</p>