JPMorganChase interview question

My coding test was similar to TwoSum problem