Skip to content

Commit 24877e0

Browse files
committed
Solution to today's problem
1 parent 4bced19 commit 24877e0

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/java/io/github/spannm/leetcode/lc1/lc1200/Problem1248.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
class Problem1248 extends LeetcodeProblem {
99

1010
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;
11+
int len = _nums.length;
12+
int[] count = new int[len + 1];
13+
count[0] = 1;
14+
int result = 0;
1515
int t = 0;
16-
for (int v : _nums) {
17-
t += v & 1;
16+
for (int n : _nums) {
17+
t += n & 1;
1818
if (t - _k >= 0) {
19-
ans += cnt[t - _k];
19+
result += count[t - _k];
2020
}
21-
cnt[t]++;
21+
count[t]++;
2222
}
23-
return ans;
23+
return result;
2424
}
2525

2626
}

0 commit comments

Comments
 (0)