Skip to main content

๐ŸŽฎ Hashing Patterns (Practice)

Companion to the Hashing Patterns guide. Prefix-sum hashing: count subarrays summing to k in O(n). Edit and run the code right here โ€” it executes in your browser.

๐Ÿ Your turnโ€‹

Loading editorโ€ฆ

๐Ÿง  Challenge yourselfโ€‹

  1. Return the actual subarray index ranges, not just the count.
  2. Longest subarray with sum k.
  3. Why does seen[0]=1 handle prefixes that themselves equal k?

Continue the learning path โ†’ Binary Search