import java.util.*; public class Solution { public ArrayList<ArrayList<Integer> > FindContinuousSequence(int sum) { if(sum < 0){ return null; } ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>(); for(int i = 1; i <= sum/2; i++){ ArrayList<Integer> subList = new ArrayList<Integer>(); int res = 0; for(int j = i; j < sum && res<sum ;j++ ){ res = res + j; if(res<sum){ subList.add(j); } if(res == sum){ subList.add(j); list.add(subList); } } } return list; } }
原文地址:https://www.cnblogs.com/q-1993/p/10911540.html
时间: 2024-10-28 11:31:52