Running sum · 累計和
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version. · このページには最新のブラウザ(SharedArrayBuffer対応)が必要です。Chrome、Edge、Firefox、Safariを最新バージョンに更新してください。
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[] を埋めていきます。
Complete runningSum(int[] nums) so result position i is the sum nums[0] + ... + nums[i]. Example: [1,2,3,4] becomes [1,3,6,10]. · runningSum(int[] nums) を完成させて、結果の i 番目の位置に nums[0] + ... + nums[i] の合計を代入してください。例: [1,2,3,4] が [1,3,6,10] に変わる。
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。