publicclassSolution{/** * @parammatrix: A list of lists of integers * @param: A number you want to search in the matrix * @return: An integer indicate the occurrence of target in the given matrix*/publicintsearchMatrix(int[][]matrix,inttarget){ // search from lower left cornerif(matrix ==null||matrix.length==0)return0;int m =matrix.length, n = matrix[0].length;int res =0;int r = m -1, c =0;while(r >=0&& c < n){if(matrix[r][c]== target){ res++; r--; c++;}elseif(matrix[r][c]> target) r--;else c++;}return res;}}