Slug: arr-prefix-01 · Paired reading: Chapter 15
Prompt
Build struct Prefix(Vec<i64>) with fn new(a: &[i64]) -> Self and
fn range_sum(&self, lo: usize, hi: usize) -> i64 summing a[lo..hi]
(half-open) in O(1) after O(n) preprocess.
The curriculum, drills, tutor, and interviewer mode are for readers of Ace the Rust Interview. The code is printed in the Preface (Companion site access).
Don’t have the book yet? The landing page stays open — purchase unlocks this gym.
intermediate · order 74
Slug: arr-prefix-01 · Paired reading: Chapter 15
Build struct Prefix(Vec<i64>) with fn new(a: &[i64]) -> Self and
fn range_sum(&self, lo: usize, hi: usize) -> i64 summing a[lo..hi]
(half-open) in O(1) after O(n) preprocess.