TikTok VO Interview Question: Linked List Top N Largest Elements

18 Views
No Comments

Given a linked list, write a function to return the top N largest elements in the list.

Return the result in descending order.

This problem asks for the top N largest values from a linked list. A common approach is to maintain a min-heap of size N while traversing the list, so only the largest N elements are kept at any time. This gives an efficient solution for a linked-list input and avoids sorting the entire list unnecessarily.

END
 0