[DAY6]Frequency Queries
1 min readOct 14, 2019
https://www.hackerrank.com/chall…/frequency-queries/problem…
Solution 1: Use one hash table to record the frequency of each number. But when searching for the frequency number, we need to traverse the array from head to tail. The time complexity wold be O(N²)
Solution 2: Use two hash tables! One for recording the frequency of each number. Another one for recording the frequency of each frequency number. The time complexity would be O(N).