other or not ?
Like 'aab' can be converted to 'bba' so we print yes otherwise no
For eg P='aab' and Q='bba'
In one operation, u can replace all occurences of a single character in P with any character from alphabet Z subject to following simple rules :
1) Replace only happens when new character doesn't already exists in P.
2) Replace operation is atomic to all occurences which means all occurences are replaced simultaneously with same character.
3) All occurences must be replaced.
Alphabet Z consists of lower case english letters only.
A few hint for you: 1. The core transformation can be modeled as a digraph. What's the meaning of vertices and edges in this problem? 2. In which scenario, the problem can't be build as a digraph (no solution)? 3. What's the property of the digraph? Are there any constraints on the in degree and out degree for the vertices? 4. What if the digraph contains loops? Are there any additional checkings to be done?
Обсуждают сегодня