Pergunta de entrevista da empresa JPMorganChase

My coding test was similar to TwoSum problem