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 d455276 commit 817bfa9Copy full SHA for 817bfa9
src/data_structures/lazy_seg_tree.rs
@@ -51,11 +51,8 @@ impl LazySegTree {
51
/// - Space: O(n)
52
pub fn build_on_array(a: &[u64]) -> Self {
53
let n = a.len();
54
- let mut pw2 = 1;
55
- while pw2 < n {
56
- pw2 *= 2;
57
- }
58
let mut tree = vec![0; 2 * n];
+ let pw2 = n.next_power_of_two();
59
for i in 0..n {
60
tree[(i + pw2) % n + n] = a[i];
61
}
0 commit comments