[testcase too weak] Abviously wrong solution passes the judge

  • 0
        bool searchMatrix(vector<vector<int>>& matrix, int target) {
            for(int i=0, j = matrix[0].size();i<matrix.size();++i) {
                auto it = lower_bound(matrix[i].begin(), matrix[i].begin()+j,target);
                if(it == matrix[i].begin()+j) continue;
                if(*it == target)return true;
                j = it - matrix[i].begin();
            return false;

    this solution fails against this test case:

    But it passes OJ.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.