We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent e724b1a commit c6c6442Copy full SHA for c6c6442
algorithms/prefix_sum/continous_sub_array_sum/__init__.py
@@ -12,8 +12,9 @@ def check_subarray_sum(nums: List[int], k: int) -> bool:
12
remainder_map: Dict[int, int] = {0: -1}
13
14
for idx, num in enumerate(nums):
15
+ cumulative_sum += num
16
# Compute the remainder of the cumulative sum with k
- remainder = (cumulative_sum + num) % k
17
+ remainder = cumulative_sum % k
18
19
# Check if the remainder has been seen before
20
if remainder in remainder_map:
0 commit comments