103Fenwick tree (Binary Indexed Tree): point updates and prefix sums in O(log n).▼mediumGoogleMetaAmazon2 replies◆ premiumA Fenwick tree answers prefix-sum queries and point updates in O(log n) with a single flat array and one bit trick. The signal is the lowbit operation and why it beats a plain prefix array under updates. Here is the answer.Open full answer →
104Segment tree: range queries and point updates for sum, min, or max in O(log n).▼hardGoogleMetaAmazon2 replies◆ premiumA segment tree answers any associative range query (sum, min, max, gcd) with point or range updates in O(log n). The signal is the recursive split into covered, disjoint, and partial nodes, plus lazy propagation for range updates. Here is the answer.Open full answer →