Agoda Interview Question

dsa round of a question based on strings