I am creating an app where the user enters 8 characters. After he enters the string I have to see if it is an eight letter word. If not, check if contains a seven letter word etc.
I am checking against a given pool of 150k+ words. I only care about the longest possible match. Is there a better way then this one:
I forgot to add that I am checking against an english dictionary.
So far I am using this:
for(i = 8; i >= 3; i--) for(j = 0; j <= 8 - i; j++) if(words.contains(word.substring(j, i)) //do something
Edit 2 I have been using the approach defined above just with a minor change. I am using a few background agents which all search for a word of a certain length. They all then return a result and I just pick the one which gives the user the highest score.