Pergunta de entrevista da empresa BlackRock

Leetcode question at medium level