Skip to content

ORIGINAL CODING QUESTION

Daily signal total

A career dashboard receives n signed activity changes. Return their total without changing their order or values.

Open practice workspace

Original exercise · easy. Editorial role relevance does not imply a company has asked this question.

Input and output

First integer n, followed by n signed integers. Print one integer.

Constraints

1 ≤ n ≤ 10,000; each change is between -10,000 and 10,000.

Example 1

Input

4
3 -2 8 1

Output

10

3 - 2 + 8 + 1 = 10.

Example 2

Input

3
-4 -2 -1

Output

-7

Negative totals remain negative.

Explain your approach

Explain your time and auxiliary space complexity. Which input makes your algorithm work hardest?

Private grading inputs, expected outputs and canonical reference implementations are withheld. Authored expected outputs were cross-checked with independent reference oracles; compiler/runtime behavior still needs a verified execution provider.

Hint 1

Use one running total.

Hint 2

Visit each activity exactly once.

Hint 3

Initialize the total to zero and add each of the n values.

Practice this question

Save your work privately, explain decisions and return to your revision queue.

Open practice workspaceBrowse the question library →