To search for an element in a sorted matrix, you can use a binary search twice. First, binary search helps find the potential row, then apply binary search on that row. Alternatively, a single binary search can be applied on the matrix treated as a 1D array. For the input mat[][] = [[1, 5, 9], [14, 20, 21], [30, 34, 43]] and x = 14, the result is true.
Read the full article for more details here.