Running sum of daily signups

Python data engineering interview problem. Difficulty: beginner. Pattern: Aggregation. About 10 minutes. Free to practice.

Growth tracks daily new signups. Finance wants a running total so day 3's number is signups from day 1 through day 3, not that day alone.

Daily signup counts are useful, but a running total shows how many signups have arrived so far. Return a new list where each item is the sum of all values up to and including that position. An empty list gives an empty list. Write running_sum(daily). [1, 2, 3] becomes [1, 3, 6] because 1, then 1+2, then 1+2+3. An empty list stays []. The starter file already has the function name and its print lines. Keep them and fill in the body.

Requirements

  • Each output item is the total so far.
  • The output has the same length as the input.
  • An empty list returns [].

Constraints

  • daily is a list of numbers.
  • The input list should not be changed.

Examples

Input: running_sum([1, 2, 3]) Output: [1, 3, 6] This input follows the stated rules and produces this output.

Topics: lakebench, python, iteration.

More Python interview questions · All interview problems · Learn data engineering

beginner

Running sum of daily signups

Interview-style drill: Given a list of daily signup counts, return the running cumulative total.

Turn a list of daily signup counts into a prefix (running) sum.