I am looking for the most efficient algorithm to form all possible combinations of words from a string. For example:
Input String: forevercarrot Output: foreve
See this question which has even better answers. It's a standard dynamic programming problem:
How to split a string into words. Ex: "stringintowords" -> "String Into Words"?