What is error in my code showing runtimeerror ,array index out of bounds


#1

Comment body goes int Solution::searchMatrix(vector<vector > &A, int B) {
int n=A.size(),m=A[0].size();//cout<<m<<n;
int i,j,u=n*m-1,l=0,mid;
while(l<u)
{
mid=(l+u)/2;//cout<<mid<<" “;
if(A[mid/m][mid%m]==B)
{
return 1;
}
if(A[mid/n][mid%m]>B)
u=mid-1;
else
{
l=mid+1;
}
}
if(l==u)
{ //cout<<” love";
if(A[l/m][l%m]==B)
{return 1;}
else {return 0;}
}
else
return 0;

}
showing run time error or array index out of bounds when 2*10 vector is coming