Kth largest element in an Array Leetcode Solutions

In this problem, we have to return the kth largest element in an unsorted array. Note that the array can have duplicates. So, we have to find the Kth largest element in the sorted order, not the distinct Kth largest element. Example A = {4 , 2 , 5 , 3 …

Read moreKth largest element in an Array Leetcode Solutions

K-th Distinct Element in an Array

You are given an integer array A, print k-th distinct element in an array. The given array may contain duplicates and the output should print k-th distinct element among all unique elements in an array. If k is more than a number of distinct elements, then report it. Example Input: …

Read moreK-th Distinct Element in an Array

How to Implement Stack Using Priority Queue or Heap?

Implement a stack with the help of a priority queue or a heap. Priority Queue : Priority queue data structure is similar to the queue or stack data structure with an addition of priority. Every element is given a priority number. In conclusion, the elements with high priority are prefered …

Read moreHow to Implement Stack Using Priority Queue or Heap?

Merge K Sorted Linked Lists

Merge K sorted linked lists problem is so famous as per the interview point of view. This question asks so many times in big companies like Google, Microsoft, Amazon, etc.  As the name suggests we’ve been provided with k sorted linked lists. We have to merge them together into a …

Read moreMerge K Sorted Linked Lists