@pei11 Thank you for your reply. He is correct... In my reply, I used n as the total number of elements in the matrix...while in his answer the total number of elements is n^2. So he is right...Thank you again.
Funny enough this solution doesn't pass multiple test cases. Need one for the empty array and another to set c
def searchMatrix(self, mat, x):
:type matrix: List[List[int]]
:type target: int
m, n, r, c = len(mat), len(mat), 0, len(mat) - 1
while r<m and c>=0: