Skip to content

Commit aee3196

Browse files
authored
Update 974.Subarray-Sums-Divisible-by-K.cpp
1 parent 2520939 commit aee3196

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

Hash/974.Subarray-Sums-Divisible-by-K/974.Subarray-Sums-Divisible-by-K.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ class Solution {
55
unordered_map<int,int>Map;
66

77
Map[0] = 1;
8-
int sum = 0;
9-
int count = 0;
8+
int presum = 0;
9+
int ret = 0;
1010
for (int i=0; i<A.size(); i++)
1111
{
12-
sum+=A[i];
13-
int r = sum > 0 ? sum%K : (sum%K+K)%K;
14-
count+=Map[r];
12+
presum += A[i];
13+
int r = presum > 0 ? presum%K : (presum%K+K)%K;
14+
ret += Map[r];
1515
Map[r]++;
1616
}
17-
return count;
17+
return ret;
1818
}
1919
};

0 commit comments

Comments
 (0)