Frequency Queries

  • + 0 comments

    Changing the boilerplate is unnecessary to avoid a timeout.

    Rather you can keep two hashmaps where the keyset of one is the set of integers in the array and the keyset of the other is the set of frequencies with which integers appear in the array.

    This allows you to perform all operations using keys rather than values, which is efficient enough that it doesn't timeout.