Pregunta de entrevista de Trulia

Very simple algorithm question