Pregunta de entrevista de Two Sigma

coding challenge with three questions on Hackerrank, with one question optional