题目链接
https://leetcode.cn/problems/he-wei-sde-lian-xu-zheng-shu-xu-lie-lcof/
思路
代码
class Solution {
public int[][] findContinuousSequence(int target) {
int i=1,j=2,s=3;
List<int[]>ls=new ArrayList<int[]>();
while(i<=target/2){
if(s==target){
int[] res=new int[j-i+1];
for(int k=i;k<=j;k++){
res[k-i]=k;
}
ls.add(res);
}
if(s>target){
s-=i;
i++;
}
else{
j++;
s+=j;
}
}
return ls.toArray(new int[0][]);
}
}