I Have a collection of integers(This can be a dynamic data source)
ArrayList<Int> data = [1,2,3,4,5,6,7]
What I am able to do
I can generate Equal data set like [1,2,3][4,5,6] [7]
using the answer from here
Question: How can I give a limit to the number of groups like max 2 so that resulting output is
[1,2,3,4][5,6,7]
or [1,2,3][4,5,6,7]