Domanda di colloquio di Trusted Positioning

During technical assessment: how would you optimize this code?