×

Loading...

My two cents

1. sort
2.a create an ArrayList<ArrayList<Integer>> listOfSeries
2.b set maxLen = 0
3. Loop through the number list
for each number
3.1 Loop through the listOfSeries
for each series in the listOfSeries
If we can add the current number to the current series, add it. Set maxLen = +1
3.2 Add a new arrayList to the listOfSeries, this arrayList contains only the current number


Take {3,8,4,5,6,2,2} as example, then the final listOfSeries consists of:

,2,2
,2,3,4,5,6
,3,4,5,6
,4,5,6
,5,6
,6,8
,8
Report