Here’s the link to the problem: CodeChef: Practical coding for everyone
I have built a graph having nodes a-z. and mapped each rule (a->b, b->c, etc) as edges of the graph.
Go through each character of both strings( say, character a and b) and check if both nodes a and b are connected using a depth-first-search.
I have got a lot of wrong answers during the contest. It might be due to few edge cases which I could miss or my approach could have been outright wrong.
Please help me figure it out.
Here’s my code: qyZW2D - Online C++ Compiler & Debugging Tool - Ideone.com