Running sum · Soma acumulada
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.
Soma acumulada
Retorne um novo array onde a posição i contém a soma de todos os elementos até e incluindo i: [1, 2, 3, 4] → [1, 3, 6, 10]. Mantenha um total acumulado e preencha um int[] fresco do mesmo comprimento.
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]. · Complete runningSum(int[] nums) para que a posição do resultado i seja a soma nums[0] + ... + nums[i]. Exemplo: [1,2,3,4] torna-se [1,3,6,10].
Click Run to see the output here. · Clique em Executar para ver a saída aqui.