Blog

Your dream job? Lets Git IT.
Interactive technical interview preparation platform designed for modern developers.

XGitHub

Platform

  • Categories

Resources

  • Blog
  • About the app
  • FAQ
  • Feedback

Legal

  • Privacy Policy
  • Terms of Service

© 2025 LetsGit.IT. All rights reserved.

LetsGit.IT/Categories/Algorithms
Algorithmseasy

What is a prefix sum array and what does it speed up?

Tags
#prefix-sum#range-query#preprocessing
Back to categoryPractice quiz

Answer

A prefix sum array stores sums up to each index. After O(n) preprocessing, you can answer range sum queries in O(1): sum[l..r] = prefix[r] - prefix[l-1]. It’s also used for counting frequencies and quick “how many in a range” queries.

Related questions

Data Structures
What is a segment tree and what complexity does it give for range queries and updates?
#segment-tree#range-query#updates
Data Structures
What is a sparse table and what problems is it good for?
#sparse-table#rmq#preprocessing
Data Structures
What is a segment tree and what is it good for?
#segment-tree#range-query#big-o
Data Structures
What is a Fenwick tree (Binary Indexed Tree) used for?
#fenwick#bit#prefix-sum