import java.util.*; public class Solution { public ArrayList<ArrayList<Integer> > FindContinuousSequence(int sum) { ArrayList<ArrayList<Integer> > res = new ArrayList<>(); if(sum < 2){ return res; } Deque<Integer> deque = new LinkedList<>(); int count = 0; for(int i = 1; i <= sum / 2 + 1; i++){ count += i; deque.addLast(i); if(count > sum) { while (count > sum) { count -= deque.pollFirst(); } } if(count == sum){ res.add(new ArrayList<>(deque)); } } return res; } }