Pregunta de entrevista de Apple

A normal graph problem usually taught in discrete math class