Question bank › Heap
Dsa Heap Hard

Kth Largest Element in a Stream

You are given a stream of integers and an integer k. Your task is to maintain the k-th largest element at any time during the stream input. Read integers from standard input until an empty line is encountered. After each integer is added, print the current k-th largest number. For example: Input: 4 2 1 5 3 8 Output: 4 4 5 5

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.