Solution to Leetcode 3092: Most Frequent IDs

Pierre-Marie Poitevin
3 min readMay 6, 2024

In this exercise, we are tracking the frequencies of some IDs, and need to return the ID with max frequency after each operation.

Collection interface

As is explained in the exercise, we essentially need to build a data structure that supports the 3 following operation:

  • Retrieve the most frequent ID
  • Increase the frequency of an ID
  • Decrease the frequency of an ID

--

--