classSolution { public: boolsearchMatrix(vector<vector<int>>&matrix, inttarget) { intm=matrix.size();intn=matrix[0].size(); intl=0,r=m*n-1; while(l<=r){ intmid=(l+r)/2; intx=matrix[mid/n][mid%n]; if(x<target){ l=mid+1; } elseif(x>target){ r=mid-1; } else{ returntrue; } } returnfalse; } };