Skip to content

Commit 55bf2e1

Browse files
committed
Runtime: 699 ms (Top 31.21%) | Memory: 9.5 MB (Top 92.20%)
1 parent 32a8673 commit 55bf2e1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

scripts/algorithms/P/Parallel Courses II/Parallel Courses II.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Runtime: 699 ms (Top 31.21%) | Memory: 9.5 MB (Top 92.20%)
12
class Solution {
23
int dp[1<<16];
34
int dfs(unordered_map<int, int>& c, int mask, int& k, int &n) {
@@ -6,11 +7,11 @@ class Solution {
67
vector<int> canJoinVec;
78
for(auto [key, value]: c) {
89
if(((value & mask) == value) and !(mask & (1<<key))) {
9-
//get course we can listen
10+
//get course we can listen
1011
canJoin |= 1<<key;
1112
canJoinVec.push_back(key);
1213
} else if(!(mask & (1<<key))) {
13-
//get courses we can not listen yet
14+
//get courses we can not listen yet
1415
canNotJoin |= 1<<key;
1516
}
1617
}
@@ -25,7 +26,7 @@ class Solution {
2526
int nMask = mask | canJoin;
2627
int left = k - bitset<16>(canJoin).count();
2728
//if there is some extra slots we can listen in this semester
28-
//pick any thing
29+
//pick any thing
2930
for(int i = 0; i < n and left; i++) {
3031
if(!(canNotJoin & (1<<i)) and !(nMask & (1<<i))) {
3132
nMask |= 1<<i; left--;
@@ -54,4 +55,4 @@ class Solution {
5455

5556
return dfs(course, 0, k, n);
5657
}
57-
};
58+
};

0 commit comments

Comments
 (0)