AST Consulting interview question

DSA Questions, about the string