Take any two adjacent distinct characters and replace it with the third character.

Given a string consisting of a,b and c's, we can perform the following operation: Take any two adjacent distinct characters and replace it with the third character. For example, if 'a' and 'c' are adjacent, they can replaced with 'b'. What is the smallest string which can result by applying this operation repeatedly?

A: 

1. 如果只有一种字符,比如a或b或c,数量为k,那么最后剩下的就是k;

2. 如果有两种以上的字符,

    1) 如果字符总数为odd,奇数,则最后剩余的字符数为1;

    2) 如果字符总数为even,偶数,则最后剩余的字符数为2;

原文地址:https://www.cnblogs.com/yayagamer/p/2263289.html