Pergunta de entrevista da empresa Vanguard

Write an algorithm and explain its complexity