We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d0f7747 commit d357e4aCopy full SHA for d357e4a
scripts/algorithms/C/Course Schedule III/Course Schedule III.cpp
@@ -1,3 +1,4 @@
1
+// Runtime: 280 ms (Top 87.39%) | Memory: 56.3 MB (Top 66.94%)
2
class Solution {
3
public:
4
bool static cmp(vector<int> &a,vector<int>&b) {
@@ -8,14 +9,14 @@ class Solution {
8
9
int sm = 0;
10
priority_queue<int> pq;
11
for(int i=0; i<courses.size(); i++) {
- pq.push(courses[i][0]);
12
+ pq.push(courses[i][0]);
13
sm+=courses[i][0]; // sum of duration of courses
14
// when there exists a course duration that is invalid and can't be completed on that day!
- if(sm>courses[i][1]) {
15
- sm-=pq.top(); // remove the biggest invalid course duration!
+ if(sm>courses[i][1]) {
16
+ sm-=pq.top(); // remove the biggest invalid course duration!
17
pq.pop();
18
}
19
20
return pq.size();
21
-};
22
+};
0 commit comments