, ?
, :
"quackdogsomethinggodknowswhatwhat"
I would have a recursive method starting at the beginning of the line, I would call a recursive method for all the words that begin the subject line, in this case “qua” and “quack” with a string containing no words (“dogomethinggodknowswhat” for a charlatan) . We return everything that is larger: 1 + the largest value returned from all calls to your method OR 0 + the method call for the line starting at index 1 ("uackdogsomethinggodknowswhat").
This will probably work best if you saved your list of words in some tree.
If you need pseudo code, ask!
source
share