ronith
6/18/2018 - 5:09 PM

Find the largest three elements in an array

Given an array with all distinct elements, find the largest three elements. Expected time complexity is O(n) and extra space is O(1).

Examples:

Input: arr[] = {10, 4, 3, 50, 23, 90} Output: 90, 50, 23