当前位置:网站首页>Leetcode 974. And K divisible subarray prefix sum
Leetcode 974. And K divisible subarray prefix sum
2022-06-09 02:40:00 【Confident little screw】
Original link :Leetcode 974. And can be K A subarray of integers 
class Solution {
public:
int subarraysDivByK(vector<int>& nums, int k) {
unordered_map<int,int> mp;
int tmp=0,res=0;
for(int i=0;i<nums.size();i++)
{
tmp+=nums[i];
int t=(tmp%k+k)%k;
res+=mp[t];
mp[t]++;
}
return mp[0]+res;
}
};
边栏推荐
- Export related knowledge
- Basic method for missing data filling (2) -- random forest (missforest) filling
- Problems and solutions in using renrenfast
- Blue Bridge Cup_ Multiple problem_ stack_ Remainder
- 动态规划/斐波那契数列
- Dynamic programming / Fibonacci series
- Exporter les connaissances pertinentes
- C # process control statement
- Jerry: if the user doesn't need to use all the keys, how should other keys be set? [chapter]
- Navicat tool batch imports JSON format data to Doris
猜你喜欢

Unity中,继承MonoBehaviour游戏对象的生命周期

(10.3)【隐写缓解】隐写防护、隐写干扰、隐写检测

Go Technology Daily (June 7, 2022) - go programmer development efficiency artifact summary

4426 divisible substring (enumeration + number theory)

Go to MFC from Win32

Docker installation redis

FFmpeg的软、硬解码方式梳理

Embracing out of hospital prescription drugs, Internet medicine should also "get rid of virtual reality"?

在业务代码中使用redis实现缓存效果

【编码推流】SRS流媒体服务器安装及使用
随机推荐
pkg-config --modversion opencvPackage opencv was not found in the pkg-config search path. Perhaps y
21、ADS使用记录之E类功放设计(中)
[MySQL from Xiaobai to expert] Part 6: transaction and JDBC programming in MySQL
Karmada v1.2 release: open a new era of full-text search
Go Technology Daily (June 7, 2022) - go programmer development efficiency artifact summary
Basic method of missing data filling (1) -- k-nearest neighbors (KNN) filling
Sectigo证书价格
Go技術日報(2022-06-07)——go程序員開發效率神器匯總
How does the technical leader bring down a team?
Unity中,继承MonoBehaviour游戏对象的生命周期
Jericho's notes on SPI host configuration parameters: 【 chapter 】
Basic method for missing data filling (2) -- random forest (missforest) filling
测试、预发布、生产环境测试时的侧重点是哪些?
20. Class E power amplifier design for ads usage record (Part 1)
Navicat tool batch imports JSON format data to Doris
杰理之SPI主机【篇】
LeetCode 1155. 掷骰子的N种方法**
Dest0g3 520 orientation web easyssti
Redis cluster setup
vins estimator ProcessImage