Pergunta de entrevista da empresa LinkedIn

What data structure would be best fitted for this piece of code?