gj.And here is my solution, beat 100% and I think it is easy to understand
if not matrix or not matrix: return False
for i in range(len(matrix)):
if target==matrix[i][-1]: return True
for j in range(len(matrix)):
if matrix[i][j]==target: return True
@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.