Skip to content

Commit 1c1d65e

Browse files
authored
Refactor nxt function for clarity and efficiency
1 parent a9c3d72 commit 1c1d65e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/data_structures_[l,r]/seg_tree.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
//! @time O(n + q log n)
1212
//! @space O(n)
1313
int nxt(int& l, int r) {
14-
int x = __lg(min(l & -l, r - l + 1));
15-
return ((l += (1 << x)) >> x) - 1;
14+
int x = __lg(min(l & -l, r - l + 1)), y = l;
15+
return l += (1 << x), y >> x;
1616
//return exchange(l, l + (1 << x)) >> x;
1717
}
1818
template<class T, class F> struct tree {

0 commit comments

Comments
 (0)