88. Find Top 3 Largest Values in an Array

You are given an array of n unsigned 8-bit integers (uint8_t). Your task is to:

  • Find the top 3 largest values from the array
  • Print the values in descending order
  • If n < 3, print all available values in descending order

Do not use any built-in sort functions. Use simple logic.


Example-1

Input: n = 6, arr = [10 90 20 80 70 30]
Output: 90 80 70


Example-2

Input: n = 2, arr = [5 200]
Output: 200 5


Example-3

Input: n = 3, arr = [1 2 3]
Output: 3 2 1


 

Loading...

Input

6 10 90 20 80 70 30

Expected Output

90 80 70