Pergunta de entrevista da empresa Zebu Infrastructure Online

Basic algorithm question