Pregunta de entrevista de ShopBack

Describe solution and time complexity