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