-
Notifications
You must be signed in to change notification settings - Fork 0
560. Subarray Sum Equals K #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| } | ||
| } | ||
| return count | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
特に問題ないと思いました。
強いていうならcumSumをcumulativeSumとしたい人もいる気がします。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ありがとうございます。
cumSumがcumulativeSumであることは、確かに自明ではないですね。
| ```javascript | ||
| const subarraySum = function(nums, k) { | ||
| const cumSumToCount = new Map() | ||
| cumSumToCount.set(0, 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この1に違和感がなければ問題ないかと思います。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
はい、違和感は無いです。
先頭の要素を含む部分列を含めるために必要です!
問題URL
問題文
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
A subarray is a contiguous non-empty sequence of elements within an array.
Example 1:
Example 2:
Constraints: