Accenture Interview Question

Asked about strings questions. Easy leet code