समस्या
Build a running sum: the value at position i is the sum of all numbers from position 0 through i.
Implement running_sum(numbers).
Input
numbers: The list of integers.
Output
Return the list of running totals.
सीमाएँ
0 ≤ length ≤ 100,000; totals fit in a 64-bit integer
उदाहरण
उदाहरण 1
इनपुट:
numbers = [1, 2, 3, 4]
अपेक्षित आउटपुट:
expected = [1, 3, 6, 10]
इनपुट:
std::vector<long long> numbers = {1, 2, 3, 4};
अपेक्षित आउटपुट:
std::vector<long long> expected = {1, 3, 6, 10};
इनपुट:
long[] numbers = new long[] {1, 2, 3, 4};
अपेक्षित आउटपुट:
long[] expected = new long[] {1, 3, 6, 10};
व्याख्या
Totals so far: 1, 1+2=3, 3+3=6, 6+4=10.
उदाहरण 2
इनपुट:
numbers = [5, -5, 5]
अपेक्षित आउटपुट:
expected = [5, 0, 5]
इनपुट:
std::vector<long long> numbers = {5, -5, 5};
अपेक्षित आउटपुट:
std::vector<long long> expected = {5, 0, 5};
इनपुट:
long[] numbers = new long[] {5, -5, 5};
अपेक्षित आउटपुट:
long[] expected = new long[] {5, 0, 5};
व्याख्या
Totals: 5, 0, 5.
संदर्भ
यह चुनौती CodeUtility के लिए अनुकूलित की गई है। ऊपर दिए गए स्टेटमेंट और सीमाओं का पालन करें।