Question bank › Prefix Sum
Dsa Prefix Sum Medium

Subarray Count with Target Sum

Given an array of integers and a target sum, count the number of contiguous subarrays that sum to the target. Implement a function that computes this using prefix sums. Example Input: 5 1 -1 0 1 1 2 Example Output: 5

Key concepts

prefix_sumsubarraycount

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.