Skip to content

Commit 582fd16

Browse files
authored
Update count-subarrays-with-more-ones-than-zeros.cpp
1 parent f69c5c2 commit 582fd16

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

C++/count-subarrays-with-more-ones-than-zeros.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@ class Solution {
66
int subarraysWithMoreZerosThanOnes(vector<int>& nums) {
77
static const int MOD = 1e9 + 7;
88

9-
int same = 0, more = 0;
109
vector<int> lookup(2 * size(nums) + 1);
1110
lookup[0 + size(nums)] = 1;
12-
int result = 0, total = 0;
11+
int result = 0, total = 0, same = 0, more = 0;
1312
for (const auto& num : nums) {
1413
total += (num == 1) ? 1 : -1;
1514
const int new_same = lookup[total + size(nums)];

0 commit comments

Comments
 (0)