Question d’entretien chez Wahed Invest

How would I optimize my code solution