1Use a 1-indexed prefix array (size n+1) to avoid off-by-one errors: prefix[0] = 0.
2For "subarray sum equals k", combine prefix sum with a HashMap: store {prefixSum: count} as you iterate.
3Prefix Sum can be extended to 2D grids — prefix[i][j] = sum of all elements in the rectangle from (0,0) to (i,j).
4Works for any associative operation, not just sum — prefix XOR, prefix product (with care for zeros).