Question bank › Heap
Dsa Heap Easy

Kth Largest Element Stream

You are receiving a stream of integers, and you need to find the Kth largest element after each new integer is added to the stream. Write a program that reads integers until EOF. The first line will contain the integer K, followed by K or more integers in the subsequent lines. For each new integer, output the current Kth largest element. Input Format: - The first line contains K (1 <= K <= 100). - The following lines contain integers, one per line. Output Format: - The Kth largest element after each integer input, one per line. Example: Input: 3 10 5 2 7 6 Output: 10 10 7 7 6

Key concepts

heapstreamkth largest

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.