标签:++ for 滑动 cpp sum return cto i++ solution
class Solution { public: vector<vector<int> > FindContinuousSequence(int sum) { vector<vector<int> > res; int left = 1; int right = 2; while(left<right){ int curSum = (right+left)/2*(right-left+1); if(curSum == sum){ vector<int> tmp; for(int i = left; i <= right; i++){ tmp.push_back(i); } res.push_back(tmp); left++; } else if(curSum < sum){ right++; } else{ left++; } } return res; } };
滑动窗口法
标签:++ for 滑动 cpp sum return cto i++ solution
原文地址:https://www.cnblogs.com/icehole/p/12114664.html