Pergunta de entrevista da empresa Amazon

I was asked this question: Search in a row-wise and column-wise sorted matrix