Java Streams Interview Question - 10 - Get Second Highest/Lowest Number using Streams

preview_player
Показать описание
Java Streams Interview Question - 10 - Get Second Highest/Lowest Number using Streams

Schedule a meeting in case of any queries/guidance/counselling:

~~~Subscribe to this channel, and press bell icon to get some interesting videos on Selenium and Automation:

Follow me on my Facebook Page:

Let's join our Automation community for some amazing knowledge sharing and group discussion on Telegram:

Naveen AutomationLabs Paid Courses:
GIT Hub Course:

Java & Selenium:

Java & API +POSTMAN + RestAssured + HttpClient:
Рекомендации по теме
Комментарии
Автор

Got this question in interview today. could not answer it. Thanks for sharing the answer.

jagadeeshbaskaran
Автор

you are explaining the things very clear. thank you

annajiraoannepu
Автор

these were helpful, appreciate the effort man

alisheheryar
Автор

My man Naveen! flexing the best content

SamiSabirIdrissi
Автор

Easiest way is
List<Integer> list = Arrays.asList(1, 2, 3, 4, 5, 2, 3, 1);
System.out.println(list.stream().distinct().sorted().collect(Collectors.collectingAndThen(Collectors.toList(),
l -> Map.of("small", l.get(1), "large", l.get(l.size() -

MaestroCoachingClasses
Автор

thanks, man for these really helpful please continue interview related video...

maharishi
Автор

It is necessary to use limit we can skip using limit for this

factandknowledge
Автор

Why not just make a sorted set, call it "int_set", from the list and then return int_set[1], and int_set[n-1] (please forgive poor syntax). Seems easier and cleaner code.

strix-nebulosa
Автор

We don't need the limit method right ? Anyway we are finding the first whatever is the limit -no need of shrinking it anyway !

AMANSINGH-yvvv
Автор

I have doubt why use find first directly skip function will work

udaybhaskar
Автор

lakin ye sab method kaise pata chalegi ki kidhar hai aur kiske under me hai

alim