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

Meta logo
Meta
Aug 8, 2026
mediumSoftware EngineerOnsiteCoding & Algorithms
5
0
Loading...