Heaps and top k interview questions
Priority queues, k-th largest, merging k lists, running median.
4 questions solved with this pattern, most asked first. Reported by candidates in public interview write-ups and reworded by Scrivio. How the reports are counted
Your progress: 0 of 4 done, 0 saved
Find the k-th largest element in an unsorted array.
Reported 55 times
Read the solutionStacks, queues and heapsExample sources
3 of the write-ups counted: geeksforgeeks.org 2020, geeksforgeeks.org 2022, geeksforgeeks.org 2020
Merge k sorted linked lists into a single sorted list.
Reported 34 times
Read the solutionStacks, queues and heapsExample sources
3 of the write-ups counted: geeksforgeeks.org 2020, geeksforgeeks.org 2019, geeksforgeeks.org 2023
Keep track of the median of a stream of numbers as each new number arrives.
Reported 21 times
Read the solutionStacks, queues and heapsExample sources
3 of the write-ups counted: geeksforgeeks.org 2018, geeksforgeeks.org 2020, geeksforgeeks.org 2014
Join n ropes into one, where each join costs the sum of the two lengths. Find the lowest total cost.
Reported 21 times
Read the solutionStacks, queues and heapsExample sources
3 of the write-ups counted: geeksforgeeks.org 2021, geeksforgeeks.org 2021, geeksforgeeks.org 2020