Skip to content

Running sum · ⁨前缀和⁩

English

Running sum

Return a new array where position i holds the sum of all elements up to and including i: [1, 2, 3, 4] → [1, 3, 6, 10]. Keep a running total and fill a fresh int[] of the same length.

中文

前缀和

返回一个新数组,位置 i 存放到 i(含)为止所有元素的和:[1, 2, 3, 4] → [1, 3, 6, 10]。维护一个累加值,并填充一个相同长度的新 int[]。

Log in or create account · ⁨登录或创建账户⁩

IGCSE, A-Level · ⁨IGCSE、A-Level⁩ & AP · ⁨与 AP⁩