Running Sum of 1D Array

Arrays + complexity · Carry one useful value forward · Warm-up · about 12 min

Why it matters

Many efficient solutions are just one careful pass with a small amount of state.

How it connects

This is the first brick: walk through an array once and keep only what matters.

Try first

Before coding, trace [1, 2, 3, 4] on paper and name the value you need to remember.

Interview cue

I use one pass and carry the prefix total forward, so time is O(n).