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.
But to do preallocation we need to suggest the order of unique words in magazine. We can use magazine.size() if we know, that the number of unique words has the same order as the size of input, but in theory there could be possible situation when someone publish 100 pages of word "hello". =)
Or even more real example: magazine is large book, like Holy Bible. The number of words is really huge, but there are not so many unique ones.
Hash Tables: Ransom Note
You are viewing a single comment's thread. Return to all comments →
Good point.
But to do preallocation we need to suggest the order of unique words in magazine. We can use magazine.size() if we know, that the number of unique words has the same order as the size of input, but in theory there could be possible situation when someone publish 100 pages of word "hello". =)
Or even more real example: magazine is large book, like Holy Bible. The number of words is really huge, but there are not so many unique ones.