Backbase Interview Question

What data structure would you use to solve the assignment in another way?