Question
Which statement about Prefix Sums on Arrays is the strongest interview answer?
- Prefix Sums on Arrays is mostly a naming style choice and has little effect on runtime or design.
- Prefix Sums on Arrays exists mainly to reduce the number of Java files in a project.
- Prefix Sums on Arrays matters only for frontend frameworks, not for core Java applications.
- A prefix-sum array stores running totals so a range sum can be answered with subtraction instead of rescanning the range.
Hint
Start with the core rule behind Prefix Sums on Arrays.
Answer and rationale
Correct answer: D. A prefix-sum array stores running totals so a range sum can be answered with subtraction instead of rescanning the range.
A prefix-sum array stores running totals so a range sum can be answered with subtraction instead of rescanning the range. This is the base concept interviewers commonly test first.
Track: Java