Pregunta de entrevista de Amazon

It was a generic two-pointer problem.