DEV Community

Abhi Raj
Abhi Raj

Posted on

1

3 ways to find second largest number in array JavaScript

are you looking for answer of how to find the second largest number in any array in JavaScript?
In this video i have explained 3 ways you can find the second largest number in any array in JavaScript, and also given their time complexity.

The first method involves sorting whose time complexity is O(nlogn)

The second method involves two for loop whose time complexity is O(n)

The second method involves just one for loop whose time complexity is also O(n)

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay