Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 815360f

Browse files
committed
summary -> sum
1 parent ec98ce5 commit 815360f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎Algorithms/Continuous Subarray Sum/README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Recently I start to learn Python, it's my first solution with Python.
22

33
If thinking it over in the normal way, the time complexity will be O(n^2), but we can do it linearly.
44

5-
Define an array `sum`, `sum[n]` means the summary of the first n + 1 items, so the summary from `nums[n]` to `nums[m]` is `sum[m] - sum[n - 1]`, we can judge if the value is the multiple of `k`. But the complexity is still O(n^2).
5+
Define an array `sum`, `sum[n]` means the sum of the first n + 1 items, so the sum from `nums[n]` to `nums[m]` is `sum[m] - sum[n - 1]`, we can judge if the value is the multiple of `k`. But the complexity is still O(n^2).
66

77
Think it further, define the remainder of `sum[m]` and `k` as `a`, and the one of `sum[n - 1]` and `k` as b, if `a` is equal to `b`, `sum[m] - sum[n - 1]` will be the multiple of `k`.
88

@@ -11,6 +11,6 @@ So it will be easy, just judge `sum[m] % k` is exsited or not, using Set to hash
1111
Two points to care:
1212

1313
- k is 0
14-
- the continuous subarray of size is at least 2, so we should define a variable `pre` to store the previous summary(maybe summary % k), and add it to the set later on.
14+
- the continuous subarray of size is at least 2, so we should define a variable `pre` to store the previous sum(maybe sum % k), and add it to the set later on.
1515

1616

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /