J.P. Morgan interview question

Which data structure is more suitable for this problem(based on the 1st written exercise)?