Prefix Sum pattern
A saved total lets us answer questions about a range without adding every value again.
Difficulty: Medium · Approach: Saved total + lookup
Open Algorithm Atlas to watch the full interactive lesson and follow every execution step.
Algorithm Atlas
Loading your lessons and saved progress.
Learn the Subarray Sum Equals K problem with a step-by-step DSA animation. Follow the Prefix Sum solution with synced C#, Python, and Java code.
A saved total lets us answer questions about a range without adding every value again.
Difficulty: Medium · Approach: Saved total + lookup
Open Algorithm Atlas to watch the full interactive lesson and follow every execution step.