Find the second biggest element from the array
Anoniem
A simple solution will be first sort the array in descending order and then return the second element from the sorted array. The time complexity of this solution is O(nlogn). A more efficient solution: 1. Initialise two variable as "first" and "second" and set them to INT_MIN an arbitrary value ~ 10^10 and first = second = INT_MIN 2. Start traversing the array 3. if current element > first then update first, that is first = current and second = first else if current second update second that is second = current 4. when finished traversing return second