Pergunta de entrevista da empresa AppFolio

Given an array, how would you return the three largest elements. Then follow up with ways to optimize.