Question d’entretien chez Meta

Is it the otimize solution? What time complexity that solution?