这个题目II和I对于python来说,都是一样的,代码都不用换。代码如下:
class Solution(object):
def searchMatrix(self, matrix, target):
"""
:type matrix: List[List[int]]
:type target: int
:rtype: bool
"""
list1 = []
for i in matrix:
list1.extend(i)
if target in list1:
return True
else:
return False