Given an array of integers and a target sum, calculate the number of contiguous subarrays where the sum of elements equals the target sum.
Explanation: Subarrays [2, 3] and [5] have a sum of 5.
Explanation: Subarray [10, 20, 30] has a sum of 60.
Explanation: Subarrays [5, 5], [5, 5], [5, 5], and [5, 5] have a sum of 10.
Count subarrays with given sum using prefix
No dry run loaded.
🚀 Practice this problem
Run code, get AI hints & track streak