Question d’entretien chez Amazon

4 Sum question, brute force to optimization.