Find the Kth largest value in array using java

You are given with array and integer K, now you need to find the kth largest value in the array.

Input
5     ----Array size
11  -----------------
4                         |
3                         |Array elements
1                         |
2   -----------------
3   ----K th Value.


Output: 3 (Since it is looking 3rd largest value in the array)

Input:
5
4
3
5
9
1
1

Output: 9 (Since it is looking for 1st largest value in the array)

Comments

Popular posts from this blog

Reasoning-Number Series

Reasoning-Letter Series

Profit and Loss