import java.util.ArrayList; public class Solution { public ArrayList<ArrayList<Integer> > FindContinuousSequence(int sum) { ArrayList<ArrayList<Integer>> res = new ArrayList<ArrayList<Integer>>(); int left = 1, right = 2; while(left < right){ int s = (right + left)*(right - left + 1)/2; if(s > sum){ left++; }else if(s < sum){ right++; }else{ ArrayList<Integer> list = new ArrayList<>(); for(int i = left; i <= right; ++i){ list.add(i); } res.add(list); right++; } } return res; } }