This is example of the problem (sequence ends if last 2 letters are “te”)
lasagna nato top operation online nervous usable levitate -> end word ended with “te”
There are around >100K words and the “end” letters are given and you cannot use same word more than once. I tried using going “backward” (find words that end with the begining of the words that end with “te”) in a recursive fashion but that takes way to long. What’s the most optimal way of finding the longest sequence?