prefix sum
📊 Precomputed cumulative sums for O(1) range queries
Cumulative sum array technique.
中文对照 · Chinese
📊 每天记下从年初到今天的总存款
想知道第 L 天到第 R 天存了多少钱,只需用 `S[R] - S[L-1]`。
Code example
pref[i] = pref[i-1] + a[i];Explore 100 bilingual word cards →
Cumulative sum array technique.
📊 每天记下从年初到今天的总存款
想知道第 L 天到第 R 天存了多少钱,只需用 `S[R] - S[L-1]`。
pref[i] = pref[i-1] + a[i];Explore 100 bilingual word cards →