1153. String Transforms Into Another String
Hash TableStringGraph Theory
Hints
Hint 1
Model the problem as a graph problem. Add an edge from one character to another if you need to convert between them.
Hint 2
What if one character needs to be converted into more than one character?
Hint 3
There would be no solution. Thus, every node can have at most one outgoing edge.
Hint 4
How to process a linked list?
Hint 5
How to process a cycle?
Hint 6
What if there is a character with no outgoing edge? You can use it to break all cycles!
Preparing judge…