Tag: priority queue
Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element. …
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. You may assume k is always valid, 1 ≤ k ≤ BST’s …
Given a string that contains characters of ASCII no more than 256, sort it in non-ascending order based on the frequency of the characters. For example, Input “tree” the …
Suppose if you are given an array of N integers, how could you find out the top K elements based on its frequencies? For example, Input: nums = , …
Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given …