Neighborhoods.com interview question

Algorithm question