Skip to content

Instantly share code, notes, and snippets.

@BridgeNB
Created June 26, 2018 20:03
Show Gist options
  • Save BridgeNB/a28dfa94ddcb99638099edaf1f654e6c to your computer and use it in GitHub Desktop.
Save BridgeNB/a28dfa94ddcb99638099edaf1f654e6c to your computer and use it in GitHub Desktop.
find most frequent word
1. getToken function takes a raw string converted to an array consisted words.
All words in that array are in lower cases, no punctuations and falsy items, sorted by alphabetical order.
2. mostFrequentWord function takes a raw string and use getToken to covert it to tokens.
Then build a dictionary (hash map) to count all words' frequency. Then use a loop to find the most frequent word.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment