Skip to main content

Practice · 3 of 3

The Wrong Acceleration

CHALLENGE
Difficulty: advanced+25 XP

**Scenario.** Array with interleaved point-updates and prefix-sum queries (n = q = 200000). Someone 'optimizes' with precomputed prefix sums rebuilt after every update. What went wrong? **Which approach is the best fit? The program only needs to print the letter.** **A)** Nothing — that is the correct structure **B)** Rebuilding prefixes after each update is O(n) per update: the array is dynamic, so the named bottleneck needs an incremental structure (Fenwick), not a static one **C)** They should have used a segment tree with lazy propagation **D)** They should have sorted the queries

Back to lesson: Practice: Optimization Drills