Pergunta de entrevista da empresa Fortinet

Write code for the problem [i just made up]