Fanatics interview question

Algorithm question regarding creating a graph