gj.And here is my solution, beat 100% and I think it is easy to understand

if not matrix or not matrix[0]: return False
for i in range(len(matrix)):
if target==matrix[i][-1]: return True
elif target<matrix[i][-1]:
for j in range(len(matrix[0])):
if matrix[i][j]==target: return True
return False
return False

stuck with the input matrix as [], which is here solved in the first line. However, I wonder if the input to be a row vector and target happens to lies inside that vector, the first line will skip the correct answer. Can someone help to point if my concern is too much? or the test case need to be improved and to get rid of useless []

@lee215 I like the one-liner, though it has different complexity. In your other solutions I don't like the redefinition of m and n. The problem already defined them to be height and width of the matrix (as is the standard in math/compsci).

I am aware that this is not the optimum solution, I am just surprised that an O(m*n) time complexity solution is accepted. My questions raises a flag about the test suite used for the submissions -- it is not sufficiently well constructed.