c++ ,4 lines,STL


  • 0
    S

    bool searchMatrix(vector<vector<int>>& matrix, int target) {

        auto start = lower_bound(matrix.begin(),matrix.end(),target,[](const vector<int> &e,const int t){
            return e.back() < t;
        });   
       return start != matrix.end() && binary_search(start->begin(),start->end(),target);
    }
    

    };


Log in to reply
 

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