Subarray Sum
Everything on SkillVeris tagged Subarray Sum — collected across the glossary, study notes, blog, and cheat sheets.
2 resources across 1 library
Interview Questions(2)
How Do You Find the Number of Subarrays That Sum to K?
You solve subarray-sum-equals-k in O(n) time by tracking a running prefix sum and a hash map of how many times each prefix sum value has occurred so far, since…
How Do You Find a Subarray With a Given Sum?
For arrays of non-negative integers, a sliding window expands and shrinks two pointers over the array to find a contiguous subarray summing to a target in O(n)…