Your Dashboard
Interview Coaching
Learn
System Design
ML System Design
Code
Behavioral
Salary Negotiation
Interview Guides
Search
⌘K
Get Premium
Leetcode 560. Subarray Sum Equals K
Count the number of contiguous, non-empty subarrays whose elements sum to k. Because nums can include negatives (so two-pointer sliding window doesn't work), use cumulative prefix sums with a hash map of frequencies to count matching previous sums in O(n) time.
Asked at:
Meta
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
All Regions
Late September, 2025
Meta
Staff
Early August, 2025
Meta
Senior
Negative numbers OK, only need to return true if subarray sum exists else false
Mid July, 2025
Meta
Senior
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.