I have a TreeSet in Java that contains Strings (specifically words). I need to write a method...
public boolean isValidPrefix(String prefix)
...which accepts a prefix as an argument and checks the TreeSet to see if any of its contained words begin with the prefix.
For example, given the prefix "CA" and a TreeSet containing {"DOG,"CAT","COW"}, my method would need to identify that there is a word "CAT" which starts with the prefix.
P.S. I would iterate through the TreeSet, but time complexity is an obvious constraint as the TreeList will be up to 200,000 words in many instances.