Question bank › Hashing
Dsa Hashing Medium

Subarray Sum Count

You are given an array of integers and a target sum. Your task is to count the number of continuous subarrays that sum up to the target sum. If the array is empty, return 0. Input Format: - The first line contains an integer n, the number of elements in the array. - The second line contains n space-separated integers representing the array elements. - The third line contains the target sum. Output Format: - Print the count of subarrays that add up to the target sum. Example: Input: 5 1 1 1 2 Output: 2

Key concepts

hashingprefix sumssubarrays

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.