count to store the frequency of prefix sums and a variable sum to keep track of the current prefix sum.result to 0, which will hold the final count of subarrays with sum equal to goal.nums, updating the prefix sum sum by adding the current element.sum - goal is in the hashmap count, add count[sum - goal] to result.sum in the hashmap count.result as the total count of subarrays with sum goal.