Frequency Queries

  • + 8 comments

    Solved it by creating two dictionaries.

    One which holds key value pair of number and its frequencies. And the other which holds key value pairs of a frequency and all the number having that particular frequency. Such as.

    number:frequency
    {4: 2, 5: 2, 3: 0, 1:1}
    
    frequency:numbers
    {0: {3}, 2: {4, 5}, 1:{1}}
    

    Full python solution Hackerrank - Frequency Queries Solution