Why start with ? Consider array with .
After processing: - - We look for in the map - If wasn't in the map, we'd miss this valid subarray The prefix sum represents the empty prefix (sum before index ). A subarray from index to has sum .
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Handling edge case
Why start with ? Consider array with .
After processing: - - We look for in the map - If wasn't in the map, we'd miss this valid subarray The prefix sum represents the empty prefix (sum before index ). A subarray from index to has sum .