Pregunta de entrevista de Morgan Stanley

2-sum problem with a few variations