second biggest

Find the second biggest element in an unsorted array – Single Traversal

Given an input array of integers, your goal is to find the second biggest element present in the array in an effective way. Note, you need to achieve this in O(n) time i.e., you should be able to find result by traversing through the array only once.

Algorithm:

Below is the efficient algorithm for doing this

Solution to find second biggest:

Output

Time Complexity – Single Traversal – O(n)

Space complexity – O(1)

Recommended Posts

Reference

Leave a Reply

avatar
  Subscribe  
Notify of