Pergunta de entrevista da empresa Palantir Technologies

About a medium difficulty Leetcode question, then runtime.