Pregunta de entrevista de Optum

Medium level coding question based on strings