I have a List<List<Integer>> like this :
[
[3, 12, 1, 14, 10],
[3, 12, 1, 15, 10],
[3, 13, 1, 12, 10],
[3, 13, 1, 15, 10]
]
I would like something like this : (the first element is just 3 because in the previous list 3 is always at first place. The second element is [12,13] because on the previous list 12 and 13 are on the second index etc...)
[[3, [12,13], [1], [12,14,15], [10]]
A Map<Integer, List<Integer>> is also a valuable option
Is it possible with Java streams to do that ?
Map<Integer, List<Integer>>. Its rather aCollection<Set<Integer>>in the manner you have posted.