Pregunta de entrevista de JPMorganChase

My coding test was similar to TwoSum problem