Pergunta de entrevista da empresa Tesla

Leetcode like question about algorithms