I want to make the second part work thanks for the help:)
If arraylist is ['A','a','B','C','C'] then dups:['A','a','C','C'] nondups: ['B'] I tried :
Map<String, Long> counts = nums.parallelStream()
.collect( Collectors.groupingBy( {k -> k.toLowerCase()}, Collectors.counting()) )
It gives counts: {a:2, b:1, c:2}
Now I am finding dups and nondups which is done by below code or alternate suggestion to solve this:
Map<Boolean, List<String>> hasDup =
counts.entrySet().parallelStream()
.collect(Collectors.partitioningBy(
entry -> entry.getValue() > 1,
Collectors.mapping(Map.Entry::getKey, Collectors.toList())));
List<String> dup = hasDup.get(true);
List<String> nodup = hasDup.get(false);
dup:['a','c'] nondups:['b'] I need help in second part because the expected output is not the same as I want which is
dups:['A','a','C','C'] nondups: ['B']
It seems you're mixing things, because the algorithm does not returns what you want even if it was a non-parallel stream. In the second part you are obtaining the key you've used to group due to duplication counting, which also is in lowercase. So, you won't retrieve the uppercase ones.
Then, what you really need is to "unroll" the dups as many times as the associated count.
Then, since it iterates over
numsto fill bothdupandnoduplists, you have the original Characters.