๐ฎ Segment/Fenwick (Practice)
Companion to the Segment Tree & Fenwick Tree guide. Build a Fenwick tree (BIT) for O(log n) prefix sums with updates. Edit and run the code right here โ it executes in your browser.
๐ Your turnโ
Loading editorโฆ
๐ง Challenge yourselfโ
- Add a range-sum query(l, r) using two prefix queries.
- What does
i & (-i)compute, and why? - When is a segment tree preferable to a Fenwick tree?
Continue the learning path โ Backtracking