Pergunta de entrevista da empresa Thought Machine

to answer an algorithm question