Pergunta de entrevista da empresa CoStar Group

Improve this psuedo code and write some SQL