Running Totals
Running totals help you quickly see how much has accumulated by each step, such as daily sales or expenses. Given a list of numbers nums, return a list of the same length. Each element should be the sum of all numbers from the start of nums through that position.
Примеры
Ввод
[1, 2, 3, 4]Вывод
[1, 3, 6, 10]Ввод
[]Вывод
[]Ввод
[5]Вывод
[5]Нужно реализовать
def running_totals(nums: list[int]) -> list[int]:
Теги
arraymath
Přihlaste se, abyste viděli historii odevzdání
Přihlásit sePřihlaste se, abyste mohli použít AI mentora
Přihlásit seVisible tests
1
Input
[1,2,3,4]Expected
[1,3,6,10]2
Input
[]Expected
[]3
Input
[5]Expected
[5]4
Input
[-1,1,-1,1]Expected
[-1,0,-1,0]5
Input
[10,0,0,5]Expected
[10,10,10,15]6
Input
[2,2,2]Expected
[2,4,6]Focus radio
Paused · SomaFM · Fluid