This was a question on my Facebook Interview:
We have two rules to replace characters in a string:
A -> 'aBabAb'
B -> 'bAbaBa'
Assume we start with S0 = A and follow these two rules to build next strings. For example the next two strings would be:
S1 = aBabAb
S2 = abAbaBaabaBabAbb
....
Write a function to return mth character in Sn.