Pergunta de entrevista da empresa Fanatics

Algorithm question regarding creating a graph