...

/

Solved Problem - Kth Largest element

Solved Problem - Kth Largest element

In this lesson, we'll discuss a solved heap problem.

Problem statement

Given an array, A[]A[], consisting of NN integers; for a given KK, find the KthK^{th} largest element in the array.

Input format

The first line consists of two integers NN and KK (1KN106)(1 \leq K \leq N \leq 10^6).

The second line consists of NN integers representing the array A[]A[] (1A[i]106)(1 \leq A[i] \leq 10^6) ...