-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Description
Bug Report for https://neetcode.io/problems/search-2d-matrix
class Solution {
public:
bool searchMatrix(vector<vector>& arr, int t) {
int i=0, j=arr.size()-1;
while(i<=j) {
int m = (i+j)>>1;
if(arr[m][0]>t) j=m-1;
else if(arr[m][0]==t) return true;
else i=m+1;
}
cout<<i<<" "<<j<<endl;
if(i>arr.size()-1) return false;
int row = j;
i=0; j=arr[row].size()-1;
while(i<=j) {
int m = (i+j)>>1;
if(arr[row][m]>t) j=m-1;
else if(arr[row][m]==t) return true;
else i=m+1;
}
return false;
}
};
When I run this code multiple times, its getting accepted at random.
Focus on the last test case.
This is the proof. After running the same code 3-4 times, its getting accepted.

Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
