class Solution {
public List[HTML_REMOVED] > findContinuousSequence(int sum) {
//1.定义两个指针small指向1 ,big指向2
int small =1;
int big =2;
ArrayList<List<Integer>> retList= new ArrayList<List<Integer>>();
if(sum<1){
return retList;
}
while(small<=(1+sum)/2){// 16/2=8 (1+8)*8 /2
ArrayList<Integer> list= new ArrayList<Integer>();
int count = (small +big)*(big-small+1 )/2; // 1,2,3,4
if(count==sum){
for(int j=small;j<=big;j++){
list.add(j);
}
retList.add(list);
// System.out.println("s "+small+" big "+big+ " i" +i);
small++;
}else if(count<sum){//比目标值小
big++;
}
else{//count>sum
small++;
}
}
return retList;
}
}