I have as input a list of n+2 continuous substrings of length 3. My goal is to find out whether there exists a string of length n such that all its continuous substrings of length 2 are exactly the input list that I have been given.
How can I efficiently solve this problem (e.g. for strings of length 4000)?
I have tried out a DP approach similiar to the one used for matrix chain multiplication but it didn't work.
Now I am thinking that I could convert this problem into a graph where the substrings are the vertices and two vertices (substrings of length 3) are connected by an edge if the substrings can be joined into a substring of length 4 (e.g. abc and bcd are connected as they can be joined into abcd). Would trying to find a Eulerian path in this graph solve my problem? Or am I completely wrong about all this?