Please explain me the approach to solve this question?

Note: It is not a question of any ongoing contest, It is just past interview experience question. So please help me out solving this question

Given a string of a,b, and/or? You can replace it? with a or b. task is to replace all? such that no three consecutive a or b occurs in the string. it is given that such string will always exist we needed to return the modified string.
2.a) input->b?aa?

1 Like

just place either of the two char and check if it is valid or not

1 Like

Hey Do you know any optimal way of solving this question because if the length of string is very large like order of 10^5 then time complexity increases