We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4bced19 commit 24877e0Copy full SHA for 24877e0
src/main/java/io/github/spannm/leetcode/lc1/lc1200/Problem1248.java
@@ -8,19 +8,19 @@
8
class Problem1248 extends LeetcodeProblem {
9
10
int numberOfSubarrays(int[] _nums, int _k) {
11
- int n = _nums.length;
12
- int[] cnt = new int[n + 1];
13
- cnt[0] = 1;
14
- int ans = 0;
+ int len = _nums.length;
+ int[] count = new int[len + 1];
+ count[0] = 1;
+ int result = 0;
15
int t = 0;
16
- for (int v : _nums) {
17
- t += v & 1;
+ for (int n : _nums) {
+ t += n & 1;
18
if (t - _k >= 0) {
19
- ans += cnt[t - _k];
+ result += count[t - _k];
20
}
21
- cnt[t]++;
+ count[t]++;
22
23
- return ans;
+ return result;
24
25
26
0 commit comments