MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / searchMatrix

Method searchMatrix

SearchInA2DMatrix.java:19–33  ·  view source on GitHub ↗
(int[][] matrix, int target)

Source from the content-addressed store, hash-verified

17 return false;
18 }
19 public boolean searchMatrix(int[][] matrix, int target) {
20
21// Find the appropriate row
22 int n=matrix.length;
23 int m=matrix[0].length;
24 boolean result=false;
25 for(int i=0;i<n;i++)
26 {
27 if(target>=matrix[i][0] && target<=matrix[i][m-1])
28 {
29 result=binSearch(matrix[i],target);
30 }
31 }
32 return result;
33 }
34}

Callers

nothing calls this directly

Calls 1

binSearchMethod · 0.95

Tested by

no test coverage detected