Pergunta de entrevista da empresa Zillow

Array manipulation. Brute force solution then optimization. Hints from interviewer if you're moving in the right direction.