Pergunta de entrevista da empresa MBC Group

A problem solving question in javascript.