Amazon Order Subarray Sum Equals K
Amazon Order Subarray Sum Equals K
MediumHash Maps100% accepted
Amazon tracks delivery order amounts. Given an integer array and integer k, return the total number of subarrays whose sum equals k.
Approach
Count subarrays with sum exactly equal to k using prefix sums and hash map.
Input
3 2
1 1 1
Output
2
More Hash Maps problems
Browse all coding problems →solution.py
Loading editor...
Test 1
Test 2
Test 3
Press Run to test your custom input, or Submit to judge against all test cases.
Sign in to continue
Create a free account to run code, submit solutions and track progress.
- Free forever — no credit card
- 10+ languages with live execution
- Points, streaks & leaderboards