Given a list of unique-valued sublists (that is to say two different sublists cannot share elements of the same value) - eg:
List[List[1, 1, 1], List[2], List[4, 4], List[7]]
how would this be transformed into a Map with a (value, size) key-value pairing?
This would result in:
{
1 : 3
2 : 1
4 : 2
7 : 1
}
Defining our List as values, I would assume that one could use streams and collect as a Map as such:
values.stream().collect(Collectors.toMap(Integer::intValue, ? ));
Currently unsure what to put in for the second parameter as it requires a value mapper but does not allow for .size() to be called upon any of the sublists.
List[List[1, 1, 1, 6], List[2], List[4, 4], List[7, 6]]? Is it expected to be{1:4,2:1,4:2,7:2}or would it be{1:3,2:1,4:2,6:2,7:1}?List[1, 1, 1, 6]does not fit this description.List[List[1, 1, 1], List[2], List[4, 4], List[7], List[1, 1], what do you expect as an output now?