Domanda di colloquio di EarnIn

Coding question on DSA and time complexity. I got a question on string manipulation.