LintCode:搜索二维矩阵 II

来源:互联网 发布:js.downcc.com 编辑:程序博客网 时间:2024/05/29 15:31

LintCode:搜索二维矩阵 II

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
0 0
原创粉丝点击