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

Method binSearch

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

Source from the content-addressed store, hash-verified

1class Solution {
2 public static boolean binSearch(int matrix[],int target)
3 {
4 int start=0,end=matrix.length-1;
5 while(start<=end)
6 {
7 int mid = start+(end-start)/2;
8 if(matrix[mid]==target)
9 return true;
10 else if(target<matrix[mid])
11 {
12 end=mid-1;
13 }
14 else
15 start=mid+1;
16 }
17 return false;
18 }
19 public boolean searchMatrix(int[][] matrix, int target) {
20
21// Find the appropriate row

Callers 1

searchMatrixMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected