Search⌘ K
AI Features

Solved Problem - Kth Largest element

Explore methods to find the Kth largest element in an array by applying sorting and min heap techniques. Understand how to maintain a heap of size K to optimize performance and analyze the time complexity for efficient implementation in competitive programming.

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) ...