Pregunta de entrevista de Capital One

Justify using one data structure over the other for this problem.