当前位置:网站首页>Leetcode 1248. Count "graceful subarray" prefix and
Leetcode 1248. Count "graceful subarray" prefix and
2022-06-09 02:40:00 【Confident little screw】
Original link :Leetcode 1248. Statistics 「 Graceful subarray 」
class Solution {
public:
int numberOfSubarrays(vector<int>& nums, int k) {
int n = (int)nums.size();
vector<int> cnt(n+1,0);
int res=0,tmp=0;
cnt[0]=1;
for(int i=0;i<nums.size();i++)
{
tmp+=nums[i]&1;
res+= tmp>=k ? cnt[tmp-k]:0;
cnt[tmp]++;
}
return res;
}
};
边栏推荐
- [homeassistant Internet access (cpolar)]
- 【网络协议】| 【01】网络字节序大端、小端
- 价值600的抖音云蹦迪直播间项目,靠直播打赏收益的风口项目源码
- NFT chain game system development | defi+nft technology construction
- toggleRowSelection()失效的2个重要影响因素
- Cve - 2022 - 30525 Replay of vulnerability
- C # process control statement
- In unity, inherit the lifecycle of monobehavior game objects
- Fight the high vision medical service of HKEx again, the gospel of short-sighted partners?
- 接口测试系列——转转交易业务场景接口测试实践
猜你喜欢

进程与线程

Go技術日報(2022-06-07)——go程序員開發效率神器匯總

Go Technology Daily (2022 - 06 - 07) - go programer Development Efficiency God Summary

Karmada v1.2 release: open a new era of full-text search

C#中的反射原理及应用

Kubernetes scheduling framework extension point

The 600 yuan Tiktok cloud bouncing Di live studio project is the source code of the tuyere project that rewards the income from live broadcasting

【网络协议】| 【01】网络字节序大端、小端

2022.6 download and installation tutorial of the latest version of mongodb

I'm sorry if I don't understand. The final battle
随机推荐
How to implement the project practice of user registration, login and logout in flask + MySQL
Golang of knowledge sharing -- a function based on whether a folder exists and whether a file exists
21、ADS使用记录之E类功放设计(中)
Blue Bridge Cup_ Frog date_ Extended Euclid
力扣解法汇总1037-有效的回旋镖
The 600 yuan Tiktok cloud bouncing Di live studio project is the source code of the tuyere project that rewards the income from live broadcasting
Indonesia widya robotics and Huawei cloud make the safety of construction sites visible
杰理之SPI 从机【篇】
Jerry's SPI host [chapter]
贪心法/哈夫曼编码
贪心法/非01背包问题
Exploration and best practice of automatic verification of object acquisition technology
Tiflash source code reading (III) design and implementation analysis of tiflash deltatree storage engine - Part 1
The high-end is weak. Can Yanghe still keep the third place in the industry?
21. Class E power amplifier design of ads usage record (medium)
CVE-2020-3187
2022年信息安全工程师考试知识点:网络安全产品的配置与使用
Formatting and parsing of simpledateformat time
gradle 查看某个包的依赖树
Knowledge points of 2022 information security engineer examination: configuration and use of network security products