We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 119144a commit d554894Copy full SHA for d554894
cpp/751-760/IP to CIDR.cpp
@@ -33,7 +33,7 @@ class Solution {
33
vector<string> ans;
34
35
while (n > 0) {
36
- long rightMost = start & -start;
+ long rightMost = start == 0 ? 1 << 30 : start & -start;
37
while (rightMost > n) rightMost /= 2;
38
ans.push_back(construct(start, rightMost));
39
n -= rightMost;
0 commit comments