Problem
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
A subarray is a contiguous non-empty sequence of elements within an array.
Examples
Example 1:
Input: nums = [1,1,1], k = 2
Output: 2Example 2:
Input: nums = [1,2,3], k = 3
Output: 2Constraints
1 <= nums.length <= 2 * 10^4-1000 <= nums[i] <= 1000-10^7 <= k <= 10^7
How to participate
Drop your solution as a comment (or link a gist) by May 7, 2026 at noon Pacific Time.
Include:
Your programming language
Brief explanation of your approach
Stated complexity
What I’ll do
By May 9, I’ll publish a Review & Lessons post with:
Annotated feedback on selected submissions
A clean reference solution
Notes on how an interviewer would evaluate your approach.
If you’re short on time this week, at least sketch your approach in prose—that’s still valuable practice.
Upcoming Wednesday paid post will be a Prefix Sum deep-dive: sum derivation, cumulative frequency map, 2D prefix sums, running sum vs. extra array.
If you’re a paid subscriber, you also get a weekly deep‑dive post and the option to request a private resume review.
Not paid yet? You can upgrade here:
© The Coding Interview Gym | paulepps.substack.com

