We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Great solution , I thought of the same idea , but I think in the second dictionary you don't need to keep track of the exact numbers for each frequency key since the question only asks about whether there is a number of a certain frequency or not so you can only keep the count of the numbers having a certain frequency key as the value for the second dictionary and update that count while inserting and deleting elements
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
Great solution , I thought of the same idea , but I think in the second dictionary you don't need to keep track of the exact numbers for each frequency key since the question only asks about whether there is a number of a certain frequency or not so you can only keep the count of the numbers having a certain frequency key as the value for the second dictionary and update that count while inserting and deleting elements