Count Subarrays with a Target Sum

Read the full interview experience this question came from →

Quick Overview

Count contiguous subarrays whose sum equals a target in O(n) time, even when values are negative or zero. Use prefix-sum frequencies to count valid starts, including subarrays that begin at index zero.

Count Subarrays with a Target Sum

Company: Meta

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: medium

Interview Round: Onsite

Overview: Count contiguous subarrays whose sum equals a target in O(n) time, even when values are negative or zero. Use prefix-sum frequencies to count valid starts, including subarrays that begin at index zero.

Read the full Meta Software Engineer interview experience this question came from

|Home/Coding & Algorithms/Meta
Meta logo
Meta
Aug 8, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
2
0
Loading...

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...