滑动窗口,维护一个区间 [l,r) 之间的和,当和小于 target时r++;等于时记录;大于时 l++,直到小于等于
class Solution {
public int[][] findContinuousSequence(int target) {
int l = 1, r = 1, n = 0;
List<int[]> list = new ArrayList<>();
while(r < target){
n += r++;
while(n > target) n -= l++;
if(n == target && r - l > 1){
int[] t = new int[r - l];
for(int i = 0; i < t.length; i++){
t[i] = l + i;
}
list.add(t);
}
}
return list.toArray(new int[list.size()][]);
}
}