Running sum
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].
Click Run to see the output here. · Нажмите Запустить, чтобы увидеть результат здесь.