标签:function var sse tar art off == ++ fun
// 双指针
var findContinuousSequence = function(target) {
let res = []
let left = 1
let right = 2
while (left < right) {
let sum = (left + right) * (right - left + 1) / 2
if (sum === target) {
let start = left
let sub = new Array(right - left + 1).fill(0).map(() => start++)
res.push(sub)
left++
} else if (sum > target) {
left++
} else {
right++
}
}
return res
};
剑指 Offer 57 - II. 和为s的连续正数序列 js
标签:function var sse tar art off == ++ fun
原文地址:https://www.cnblogs.com/fazero/p/13789626.html