File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed
leetcode/1799. Maximize Score After N Operations Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -88,8 +88,8 @@ public:
88
88
int cnt = __ builtin_popcount(m);
89
89
if (cnt % 2) continue; // if there are even number of elements in this subset, skip
90
90
vector<int > b; // indexes of elements in this subset
91
- for (int i = 0; i < 20; ++i) {
92
- if (m >> i & 1) b.push_back(i); // ` m ` is bit 1 at position ` i ` , which means that ` A[i] ` is in the current subset
91
+ for (int tmp = m, i = 0; tmp; ++i, tmp >>= 1 ) {
92
+ if (tmp & 1) b.push_back(i); // ` m ` has bit 1 at position ` i ` , which means that ` A[i] ` is in the current subset
93
93
}
94
94
for (int i = 0; i < b.size() ; ++i) {
95
95
for (int j = i + 1; j < b.size(); ++j) { // use different pairs as the last operation on this subset
You can’t perform that action at this time.
0 commit comments