I know algorithm of lexicographic order but in this question we can have repetition of character non-consecutively.And this make me confused.
A good string s is the one which:
- contains only these letters of the set: [a,b,c]
s[i] != s[i+1]
string aba, bca,cbc is valid but aaa, abb, aab not valid.
Order of set:[a, b, c]
["aba", "abc", "aca", "acb", "bab", "bac", "bca", "bcb", "cab", "cac", "cba", "cbc"].
Can you help me out with its algorithm.