Pregunta de entrevista de Amazon

Tries and back tracking question