Domanda di colloquio di Google

Typical algorithm question on CS - you need to know graphs for this.