Fanatics Interview Question

Algorithm question regarding creating a graph