dsa2 min read
Relative Ranks
Assign gold/silver/bronze or rank numbers to athletes based on their scores using sorted ordering.
Read →
webcoderspeed.com
1276 articles
Assign gold/silver/bronze or rank numbers to athletes based on their scores using sorted ordering.
Find K closest elements to x in a sorted array using binary search to find the optimal left boundary.
Find the Kth largest element using quickselect O(n) average or a min-heap of size K in O(n log k).
Return the K most frequent elements using a frequency map plus min-heap, or bucket sort for O(n) solution.
Sort characters in a string by decreasing frequency using a frequency counter and max-heap or bucket sort.