Pregunta de entrevista de Amazon

Q1. Based on the string. Q2. This is also based on string