Domanda di colloquio di Neighborhoods.com

Algorithm question