Question bank › Heap
Dsa Heap Medium

K Largest Unique Elements

Write a program that takes a list of integers and outputs the k largest unique elements. If there are fewer than k unique elements, return 'Not enough unique elements'. Input: - The first line contains two integers n (number of elements) and k (the required unique largest elements). - The second line contains n integers separated by spaces. Output: - A list of the k largest unique elements or 'Not enough unique elements'. Example: Input: 7 3 5 3 5 1 4 2 3 Output: [5, 4, 3]

Key concepts

heapuniquesselection

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 Praxari's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.