String question - how to approach and solve it please help

ques-

WORDAKSHARI
Antakshari is a popular parlor game played in India. Many word games are similar to antakshari. One such game is wordakshari. The game can be played by two or more people. The first player has to recite a word. The last letter of the word is then used by the next player to recite another word starting with that letter. The winner or winning team is decided by a process of elimination. The person or the team that cannot come up with a word with the right consonant is eliminated. The following rules need to be followed while playing this game. (ii) All other words have to begin with the last letter of the previous word (iii) No words can be repeated. write a program to print the wordakshari chain.
Input Fromat:

Input consists of n+1 lines.

The first n lines contain strings corresponding to the words in the chain.

The last line of input contains the string #### to mark the end of input.

Output Format:

The output consists of the valid wordakshari chain.

The first word can begin with any letter.

Sample Input:

architect

tailor

referee

electrician

nurse

blacksmith

Sample Output:

architect

tailor

referee

electrician

nurse

sample input

oracle
error
rohit

output
oracle
error
rohit

Hi @hunt
can u pls provide the link for d question

it’s private contest…I have pasted question from there…

Ohk,
then if we just have to check the chain of words, u can store the chain in vector and compare the ending and starting letter of words and if they dont match delete the word accordingly.
in dis approach u will have to take care of one thing that is to check which word to delete like ‘abc’,‘bca’ we know any of them can be deleted.
if we dont have to preserve the chain , then ig mapping will work and make things easier to handle
I will try to think of an approach for dis question and will get back to u