The Idea: Treat the matrix as a regular array. In memory, this is how a matrix is actually laid out. If we do this, the problem simply becomes a plain old 1d binary search problem with a few minor modifications. First, we need to address 1D->2D indexing. To do this, we check to see how many rows fit the index. This will becomes the row index. The column index then simply becomes the remainder of the row size. Finally, there is an edge case with finding the maximum element in the matrix. This is why I placed another if else condition forfront == end. This ensures that when the front reaches the end, and the element is not contained within this final index, then false is returned.