Subarrays Summing to a Target

Talk it through with a coach who asks guiding questions and gives hints until you reach the answer. Pass to mark the challenge as completed.

The problem

  • medium
  • Pro

Given a list of integers, which may include negatives, and a target, count how many contiguous stretches of the list add up exactly to the target. Explain why a sliding window doesn't work here, and what does.

Talk this problem through with an AI coach

This is a Pro challenge. Sign in with Google, then upgrade to start a voice session.

Start free →