Java Streams Interview Question - 06 - Print Duplicate Numbers using Streams
Вставка
- Опубліковано 18 жов 2024
- Java Streams Interview Question - 06 - Print Duplicate Numbers using Streams
Schedule a meeting in case of any queries/guidance/counselling:
calendly.com/n...
~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:
www.youtube.co...
Follow me on my Facebook Page:
/ naveenqtpexpert
Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:
t.me/joinchat/...
Naveen AutomationLabs Paid Courses:
GIT Hub Course:
naveenautomati...
Java & Selenium:
naveenautomati...
Java & API +POSTMAN + RestAssured + HttpClient:
naveenautomati...
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.
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
Set all=l.stream().filter(
n-> l.stream().filter(x->x==n).count()>1
).collect(Collectors.toSet());
This was good !
Thank you so much for the video. Very useful. Please keep it up
I think Set method is optimised take O(n) time . freq method might be take O(n2) time
Thank you Naveen, it is greatful to use Streams
Can you please explain using stream how find out highest occurrence number in array
Thanks Naveen. It's very helpful
Very useful. Thank you.
We have distinct functionality in streams. numbers.stream().distinct();
Thanks bro
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!
How to get duplicates with their counts and return map?
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