Actual filtering is happening due to the feature of set and due to Collections.frequency operation. To prove this try collecting it to a list instead of set
Thanks Naveen...One of my friend suggested me..to watch your videos which is so helpful for me.I got job.todY as automation engineer..thank you so much.
Set set = new HashSet(); return list.stream().filter(num -> !set.add(num)) // Keep only duplicates .distinct() // to ensure unique duplicates .toList();
Actual filtering is happening due to the feature of set and due to Collections.frequency operation. To prove this try collecting it to a list instead of set
Thanks Naveen...One of my friend suggested me..to watch your videos which is so helpful for me.I got job.todY as automation engineer..thank you so much.
Thank you Naveen, it is greatful to use Streams
Thank you so much for the video. Very useful. Please keep it up
Set all=l.stream().filter(
n-> l.stream().filter(x->x==n).count()>1
).collect(Collectors.toSet());
This was good !
Thanks Naveen. It's very helpful
I think Set method is optimised take O(n) time . freq method might be take O(n2) time
Very useful. Thank you.
Can you please explain using stream how find out highest occurrence number in array
Thanks bro
We have distinct functionality in streams. numbers.stream().distinct();
never heard we could do it this way also
Waiting for more videos
second solution would not work if we have accourence more than two times, we have to use distinct() method there!
No need to use collectors.toset(), collectors.toList() will work. Can someone please correct me if I am wrong
List won't work if there is a tripled number
How to get duplicates with their counts and return map?
your teaching is very helpful but i think sir u don't know about distinct() method......
Set set = new HashSet();
return list.stream().filter(num -> !set.add(num)) // Keep only duplicates
.distinct() // to ensure unique duplicates
.toList();