Pergunta de entrevista da empresa Geotab

Can you give another solution for the coding question?