选用滑动窗口的思路
题解
class Solution {
public int[][] findContinuousSequence(int target) {
int i=1,j=1;
List<int[]> arr = new ArrayList<>();
int sum = 0;
while(i<=target/2){
if(sum>target){
sum-=i;
i++;
}else if(sum<target){
sum+=j;
j++;
}else{
int[] res = new int[j-i];
for(int k = i; k<j; k++){
res[k-i] = k;
}
arr.add(res);
//左边界向右移动
sum-=i;
i++;
}
}
return arr.toArray(new int[arr.size()][]);
}
}