class Solution:
"""
@param matrix: An list of lists of integers
@param target: An integer you want to search in matrix
@return: An integer indicates the total occurrence of target in the given matrix
"""
def searchMatrix(self, matrix, target):
# write your code here
ans = 0
for i in range(len(matrix)):
for j in range(len(matrix[i])):
if matrix[i][j] == target:
ans += 1
break
return ans
LintCode:搜索二维矩阵 II
最新推荐文章于 2019-11-19 15:37:45 发布