Skip to content

Commit 368880a

Browse files
committed
nit to bit walk
1 parent cea2689 commit 368880a

File tree

1 file changed

+5
-5
lines changed
  • library/data_structures/bit_uncommon

1 file changed

+5
-5
lines changed
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
//! Requires s[i] >= 0
2-
//! max pos such that sum of [0,pos) < sum, or -1
2+
//! max r such that sum of [0,r) < sum, or -1
33
int walk(ll sum) {
44
if (sum <= 0) return -1;
5-
int pos = 0;
5+
int r = 0;
66
for (int pw = bit_floor(size(s)); pw; pw >>= 1)
7-
if (pos + pw <= sz(s) && s[pos + pw - 1] < sum)
8-
pos += pw, sum -= s[pos - 1];
9-
return pos;
7+
if (r + pw <= sz(s) && s[r + pw - 1] < sum)
8+
sum -= s[(r += pw) - 1];
9+
return r;
1010
}

0 commit comments

Comments
 (0)