题解
class Solution {
public:
long long countInterestingSubarrays(vector<int>& nums, int modulo, int k) {
int a[100010];
unordered_map<int, int> mp;
mp[0] = 1;
long long ans = 0;
int pre = 0;
for(int x : nums)
{
pre += x % modulo == k;
ans += mp[(pre-k+modulo) % modulo];
mp[pre%modulo]++;
}
return ans;
}
};
标签:pre,leetcode2845,modulo,int,long,mp,数组,ans,趣味
From: https://www.cnblogs.com/Maxx-el/p/17765902.html