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.
I ended up creating a frequancy dictionary to store the frequancy as a key, and a Hash Set of values. I did this because the key needs to be unique, and in most cases, using a frequancy dictionary of integers alone would fail.
If you follow this path, always remember to remove the value from the current frequancy hash set before you move it onto the next, whenever you add or subtract. Don't worry about removing the entry, if there are no more values in a certain frequencies Hash Set. Just check that the Hash Set has a Count greater than 0, when asserting that the frequancy can be found.
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 →
I ended up creating a frequancy dictionary to store the frequancy as a key, and a Hash Set of values. I did this because the key needs to be unique, and in most cases, using a frequancy dictionary of integers alone would fail.
If you follow this path, always remember to remove the value from the current frequancy hash set before you move it onto the next, whenever you add or subtract. Don't worry about removing the entry, if there are no more values in a certain frequencies Hash Set. Just check that the Hash Set has a
Count
greater than0
, when asserting that the frequancy can be found.