To search for an element in a row-wise sorted matrix, you can use the naive approach, which involves traversing the entire matrix with a time complexity of O(nm). Alternatively, the expected approach applies binary search on each row, reducing the time complexity to O(nlog(m)). For the input mat[][] = [[3, 4, 9], [2, 5, 6], [9, 25, 27]] and x = 9, the result is true.
Read the full article for more details here.