This soln. works perfectly fine. But when I implement the binary search manually by iterating over the matrix elements, finding mid, etc, I’m getting errors. Can someone post a soln with the working manual bin search please?
int Solution::searchMatrix(vector<vector<int> > &A, int B) {
int r = A.size();
int c = A[0].size();
int ind = 0;
for(int i = 0; i<r; i++){
if(A[i][c-1] == B || A[i][0] == B) return 1;
else if(A[i][c-1] > B && A[i][0] < B){
ind = i;
break;
}
}
if(binary_search(A[ind].begin(), A[ind].end(), B)) return 1;
else return 0;
}