Skip to content

Commit 817bfa9

Browse files
authored
nit (#102)
Co-authored-by: Luke Videckis <[email protected]>
1 parent d455276 commit 817bfa9

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

src/data_structures/lazy_seg_tree.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,8 @@ impl LazySegTree {
5151
/// - Space: O(n)
5252
pub fn build_on_array(a: &[u64]) -> Self {
5353
let n = a.len();
54-
let mut pw2 = 1;
55-
while pw2 < n {
56-
pw2 *= 2;
57-
}
5854
let mut tree = vec![0; 2 * n];
55+
let pw2 = n.next_power_of_two();
5956
for i in 0..n {
6057
tree[(i + pw2) % n + n] = a[i];
6158
}

0 commit comments

Comments
 (0)