```
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
row = len(matrix)
if row == 0:
return False
col = len(matrix[0])
i = 0
j = col - 1
while i < row and j >= 0:
if target < matrix[i][j]:
j -= 1
elif target > matrix[i][j]:
i += 1
else:
return True
return False
```