Pergunta de entrevista da empresa Citadel

It was a Leetcode medium question