Fenwick tree (BIT)

hard

Node i covers the last (i & −i) elements ending at i - the binary representation of the index *is* the range decomposition. Half the code and half the memory of a segment tree.

Worst O(log n)Space O(n)
Loading the fenwick tree (bit) engine…

Where to go next