Skip to content

Commit c6c6442

Browse files
committed
fix(algorithms, prefix-sum, continuous-sub-array-sum): update cumulative sum
1 parent e724b1a commit c6c6442

File tree

1 file changed

+2
-1
lines changed
  • algorithms/prefix_sum/continous_sub_array_sum

1 file changed

+2
-1
lines changed

algorithms/prefix_sum/continous_sub_array_sum/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ def check_subarray_sum(nums: List[int], k: int) -> bool:
1212
remainder_map: Dict[int, int] = {0: -1}
1313

1414
for idx, num in enumerate(nums):
15+
cumulative_sum += num
1516
# Compute the remainder of the cumulative sum with k
16-
remainder = (cumulative_sum + num) % k
17+
remainder = cumulative_sum % k
1718

1819
# Check if the remainder has been seen before
1920
if remainder in remainder_map:

0 commit comments

Comments
 (0)