Caching lengths and frequencies of lettered words in a paragraph | Code Samurai
Caching lengths and frequencies of lettered words in a paragraph
Suppose that we have a very short paragraph like this "Roses are red. Violets are blue. This verse doesn't rhyme. And neither does this one," how can we find and save all different word lengths and their frequencies of occurrence? For example, "red" is 3 letter long and there are a total of five letters of this length (are, red, are, and, one) in the paragraph. Then one of the items in our cache should be 3 and 5
Just like other problems where we have to keep track of the number of occurrences, we should use a hash table. The algorithm is like this:
Read full article from Caching lengths and frequencies of lettered words in a paragraph | Code Samurai
No comments:
Post a Comment