The input is a list of names in random order. We need a function that chains elements of the list in such a way that the last character of an name is the same as the first one of the next name.
For instance:
- Input: [“Raymond”, “Nora”, “Daniel”, “Louie”, “Peter”, “Esteban”]
- Output: [“Peter”, “Raymond”, “Daniel”, “Louie”, “Esteban”, “Nora”]
There should be only one solution, so the first element is unique.