Priority queue interview questions

Top K Frequent Keywords

Given a list of reviews, a list of keywords and an integer k. Find the most frequent k keywords in order of most to least frequently mentioned. The comparison of ...
Read More

Priority Queue problems

A priority queue a data structure that keeps things in order of priority. The question is how is it different from the monotonic queue we discussed earlier. The difference is ...
Read More

Minimum cost of connecting n ropes

Given n ropes of different lengths, connect these ropes in one rope. The cost to connect two ropes is equal to the sum of their lengths. We have to connect ...
Read More

Most frequent words in file

Most frequent words in file In last post:  find K smallest element in an array, we learned some concepts to find top or bottom element in a given set. Let's ...
Read More

Median of integers stream

Median of integers stream We solve two problems which involved streams, first was to find first non repeated character in stream and second was LRU cache. Let's discuss another problem ...
Read More

Merge k sorted arrays

Given k sorted arrays of varying lengths, merge these k sorted arrays into one sorted array. For example, given 3 arrays: The resulting array should be like Microsoft, Amazon, Facebook, ...
Read More

Heaps fundamentals

In this post will learn heap fundamentals, which are very important for solving priority queue problems. Heap is a kind of data structure based on the complete tree principle. By ...
Read More

Find Kth smallest element in array

Given an array of integers which is non sorted, find kth smallest element in that array. For example: if input array is A = [3,5,1,2,6,9,7], 4th smallest element in array ...
Read More