Pergunta de entrevista da empresa Meta

It was a leetcode question