Frequency

7 articles

dsa2 min read

Top K Frequent Elements

Return the K most frequent elements using a frequency map plus min-heap, or bucket sort for O(n) solution.

Read →
dsa1 min read

Sort Characters By Frequency

Sort characters in a string by decreasing frequency using a frequency counter and max-heap or bucket sort.

Read →
dsa2 min read

Maximum Frequency Stack

Design a stack that pops the most frequent element, breaking ties by most recently pushed, using frequency-bucket stacks.

Read →