当前位置:网站首页>The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
The sword refers to Offer 57 - II. and is a continuous positive sequence of s (sliding window)
2022-08-09 13:47:00 【A pig to】
剑指 Offer 57 - II. 和为s的连续正数序列(滑动窗口)
class Solution {
public:
vector<vector<int>> findContinuousSequence(int target) {
vector<vector<int>>vec;
vector<int> res;
for (int l = 1, r = 2; l < r;){
int sum = (l + r) * (r - l + 1) / 2;
if (sum == target) {
res.clear();
for (int i = l; i <= r; ++i) {
res.emplace_back(i);
}
vec.emplace_back(res);
l++;
} else if (sum < target) {
r++;
} else {
l++;
}
}
return vec;
}
};
边栏推荐
- JVM之配置介绍(一)
- Rust from entry to proficient 04 - data types
- NFS pays special attention to the problem of permissions
- 周末看点回顾|我国IPv6网络全面建成;2022昇腾AI开发者创享日·南京站成功举办…
- FPGA中串口通信的时钟频率和波特率计数
- Extract EventBus encapsulation to base class using annotations
- [极客大挑战 2019]Upload
- 工作任务统计
- 批量读取word docx文件指定表格内容,保存在excel文件中
- ansible-cmdb friendly display ansible collects host information
猜你喜欢

Flutter introduction advanced trip (5) Image Widget
![[HCIP Continuous Update] Principle and Configuration of IS-IS Protocol](/img/4f/035432ac84644c4bd46573aa0ab7cd.png)
[HCIP Continuous Update] Principle and Configuration of IS-IS Protocol

WSA toolkit installed app store tip doesn't work how to solve?

kustomize entry example and basic syntax instructions

某高校的R语言数据分析期末作业

Explanation of RTSP protocol

Uni - app - uview Swiper shuffling figure component, click on the links to jump (click to get the item after the row data, remove data operation)

The FPGA - work summary recently

从NPU-SLAM-EDA技术分析

5G China unicom AP:B SMS ASCII 转码要求
随机推荐
绘制混合密度函数图以及添加分位数线
telnet+ftp 对设备进行 操控 和 升级
ftplib+ tqdm upload and download progress bar
昇腾AI开发者创享日南京站!一起CANN机器狗+AI机械臂实现硬核智慧救援!燃爆现场~
SQL Server查询优化 (转载非原创)
Redis源码剖析之字典(dict)
农村区县域农业电商如何做?数字化转型如何进行?
第六届“强网杯”全国网络安全挑战赛
WSA toolkit installed app store tip doesn't work how to solve?
jenkins api create custom pipeline
Go Affair, How to Become a Gopher and Find a Go Job in 7 Days, Part 1
RTSP协议的实现
FPGA-在ISE中错误总结(更新中)
剑指offer,剪绳子2
5G China unicom repeater network management protocol real-time requirements
十六进制字符→十进制数字
Rust from entry to proficient 04 - data types
我的2020年终总结
handwritten big pile
ViewPager fragments of nested data blank page abnormal problem analysis