Domanda di colloquio di Lyft

Was not expecting graph theory question