// 双指针
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
};

相关文章:

  • 2022-12-23
  • 2021-09-14
  • 2021-10-28
  • 2021-08-24
  • 2021-09-24
  • 2021-05-16
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2021-06-16
  • 2021-11-07
  • 2021-12-30
  • 2021-06-20
  • 2022-01-10
  • 2021-11-21
  • 2022-12-23
相关资源
相似解决方案