2021年2月5日星期五

Java - Grouping Array into smaller Arrays

This is bending my brain and wondering if I could get a suggestion.

The grouping of sublists will depend on the size of the original group which will vary. But if I have this :

 [0,    1,  2,   3,     4,  5,  6,  7,  8,  9,  10,     11]  

I need those grouped into this

 [0,     4,       8]   [1,     5,       9]   [2,     6,       10]   [3,     7,       11]  

and if I have this:

 [0,    1,  2,   3,     4,  5,  6,  7]  

I will need it split into 4 like this:

 [0,     4]   [1,     5]   [2,     6]   [3,     7]  

I will need to find the smallest of each smaller group but I can handle that.

Edited: Sorry forgot to mention that this shows 4 arrays each time but it could be 3 or 5 or another value. I think that makes this even more complex.

https://stackoverflow.com/questions/66070309/java-grouping-array-into-smaller-arrays February 06, 2021 at 04:42AM

没有评论:

发表评论