LintCode-剑指Offer-(38)搜索二维矩阵Ⅱ

来源:互联网 发布:centos 安装不上ibus 编辑:程序博客网 时间:2024/06/01 12:18
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;    }};
0 0
原创粉丝点击