class Solution {
public:
/**
* @param matrix: A list of lists of integers
* @param target: An integer you want to search in matrix
* @return: An integer indicate the total occurrence of target in the given matrix
*/
int searchMatrix(vector<vector<int> > &matrix, int target) {
// write your code here
int count=0;
for(int i=0;i<matrix.size();i++){
for(int j=0;j<matrix[i].size();j++){
if(matrix[i][j]==target)
{
count++;
}
}
}
return count;
}
};
LintCode-剑指Offer-(38)搜索二维矩阵Ⅱ
最新推荐文章于 2018-08-13 16:41:05 发布