Skip to content

Commit d554894

Browse files
authored
751. IP to CIDR
1 parent 119144a commit d554894

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cpp/751-760/IP to CIDR.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Solution {
3333
vector<string> ans;
3434

3535
while (n > 0) {
36-
long rightMost = start & -start;
36+
long rightMost = start == 0 ? 1 << 30 : start & -start;
3737
while (rightMost > n) rightMost /= 2;
3838
ans.push_back(construct(start, rightMost));
3939
n -= rightMost;

0 commit comments

Comments
 (0)