Input: "tableapplechairtablecupboard..." many words What would be an efficient algorithm to split such text to the list of words and get: Output: ["table", "apple", "chair", "table", ["cupboard", ["cup", "board"]], ...] First thing that cames to mind is to go through all possible words (starting with first letter) and find the longest word possible, continue from position=word_position+len(word) P.S. We have a list of all possible words. Word "cupboard" can be "cup" and "board", select longest. Language: python, but main thing is the algorithm itself. Continue reading...