K Largest Elements

medium
1. You are given a number n, representing the size of array a.
2. You are given n numbers, representing elements of array a.
3. You are given a number k.
4. You are required to find and print the k largest elements of array in increasing order.

Input Format

Input is managed for you

Output Format

Print the k largest elements of array in increasing order in separate lines.

Constraints

1 <= n <= 30
0 <= n1, n2, .. n elements <= 100
0 < k <= n

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
13
12
62
22
15
37
99
11
37
98
67
31
84
99
4
Output
84
98
99
99
Previous
Traversals In A Generic Tree (pre Order And Post Order)
Next
N Bit Grey Code

Related Questions