Description
Submission
class Solution { public: int scheduleCourse(vector<vector<int>>& courses) { sort(courses.begin(), courses.end(), [](vector<int>& v1, vector<int>& v2) { return v1[1] < v2[1]; }); priority_queue<int> pq; int day = 0; for(auto& course: courses) { pq.push(course[0]); day += course[0]; if(day > course[1]) { day -= pq.top(); pq.pop(); } } return pq.size(); } };