Pergunta de entrevista da empresa Neighborhoods.com

Algorithm question