I have an array of strings String[] words
and a 28000 word Word-list.
I want to check if any member of the String array is in the WordList (the word-list is in a text file wordlist.txt)
What is the most efficient way to go about this?
Place the strings directly into a HashSet<String>
rather than an array and iterate through the file using contains
on the set to check the content. You wont improve on O(1) access. This will also mimimize memory used to store the Strings
should any duplicates exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With