C++ beat 100% so far, simple and easy


  • 2
    L

    code below

    bool canAttendMeetings(vector<Interval>& intervals) {
        sort(intervals.begin(), intervals.end(), [](const Interval& a, const Interval& b){ return a.start < b.start; });
        int currend=INT_MIN;
        for(int i = 0; i < intervals.size(); ++i) {
            if(intervals[i].start < currend) { return false; }
            currend = intervals[i].end;
        }
        return true;
    }

  • 0
    G

    @learnfromnk why do you use "const Interval& a" could it be donde with just "Interval a"?


Log in to reply
 

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