Given a string abccc,
Given are below operations
b can be replaced by ca can be replaced by bCan the given string converted to all of the same charcters?
The string abccc can be converted to ccccc by following operations:
b at index 1 to ca at index 0 to bb at index 0 to cThe given operations can be performed infinite number of times on the string. We need to find whether the string can be converted to a string containing all same characters.
Note : the operations can be performed in any order and any number of times.
Example 1:
Input :
String - abccc
Operations -
b --> ca --> bOutput - YES
Example 2:
String - abcdc
Operations:
b --> ca --> dOutput - NO